diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 68a954c..813906d 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,6 +1,3 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - name: Python package on: @@ -11,16 +8,16 @@ on: jobs: build: - runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies and the package diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 82b16e5..c0abc72 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,16 +1,16 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.8.0 + rev: 5.13.2 hooks: - id: isort args: ["--profile", "black"] - repo: https://github.com/psf/black - rev: 21.5b0 + rev: 25.1.0 hooks: - id: black language_version: python3 - - repo: https://github.com/myint/autoflake - rev: v1.4 + - repo: https://github.com/PyCQA/autoflake + rev: v2.3.1 hooks: - id: autoflake args: diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index a7da3fc..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -include requirements.txt -include LICENSE diff --git a/pyproject.toml b/pyproject.toml index 9f1d014..ebcc785 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,49 @@ [build-system] -requires = [ - "setuptools >= 40.9.0", - "wheel" -] +requires = ["setuptools>=68.0", "wheel"] build-backend = "setuptools.build_meta" + +[project] +name = "sciunit" +version = "0.3.0.dev.0" +description = "A test-driven framework for formally validating scientific models against data." +readme = { file = "README.md", content-type = "text/markdown" } +license = "MIT" +authors = [ + { name = "Rick Gerkin", email = "rgerkin@asu.edu" } +] +requires-python = ">=3.9" +classifiers = [ + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", +] +dependencies = [ + "bs4", + "cerberus>=1.2", + "deepdiff", + "gitpython", + "importlib-metadata", + "ipykernel", + "ipython", + "jsonpickle", + "lxml", + "matplotlib", + "nbconvert", + "nbformat", + "pandas>=0.18", + "quantities>=0.13.0", +] + +[project.urls] +Homepage = "http://sciunit.scidash.org" + +[project.scripts] +sciunit = "sciunit.__main__:main" + +[tool.setuptools.packages.find] +where = ["."] +include = ["sciunit*"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 8b13789..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/sciunit/capabilities.py b/sciunit/capabilities.py index 696a253..4e713f3 100755 --- a/sciunit/capabilities.py +++ b/sciunit/capabilities.py @@ -46,10 +46,10 @@ def source_check(cls, model: "sciunit.Model") -> bool: dis_output = [word for word in dis_output if word] if ( - "(NotImplementedError)" in dis_output - or "(unimplemented)" in dis_output - or "(CapabilityNotImplementedError)" in dis_output - or "(NotImplemented)" in dis_output + any("NotImplementedError" in t for t in dis_output) + or any("unimplemented" in t for t in dis_output) + or any("CapabilityNotImplementedError" in t for t in dis_output) + or any("NotImplemented" in t for t in dis_output) ): cap_source = inspect.getsource(getattr(cls, method)) model_source = inspect.getsource(getattr(model, method)) diff --git a/sciunit/scores/collections.py b/sciunit/scores/collections.py index 1e27049..62042a7 100644 --- a/sciunit/scores/collections.py +++ b/sciunit/scores/collections.py @@ -315,7 +315,7 @@ def __setattr__(self, attr, value): @property def related_data(self) -> pd.DataFrame: - return self.applymap(lambda x: x.related_data) + return self.map(lambda x: x.related_data) @property def scores_flat(self) -> list: @@ -323,7 +323,7 @@ def scores_flat(self) -> list: @property def scores(self) -> pd.DataFrame: - return self.applymap(lambda x: x.score) + return self.map(lambda x: x.score) score = scores # Backwards compatibility @@ -334,7 +334,7 @@ def norm_scores(self) -> pd.DataFrame: Returns: DataFrame: The DataFrame instance that contains norm scores as a matrix. """ - return self.applymap(lambda x: x.norm_score) + return self.map(lambda x: x.norm_score) def stature(self, test: Test, model: Model) -> int: """Computes the relative rank of a model on a test compared to other models that were asked to take the test. @@ -392,7 +392,7 @@ def _repr_html_(self): if self.show_mean: sm = sm.add_mean() if self.colorize: - obj = sm.style.applymap(sm.apply_score_color) + obj = sm.style.map(sm.apply_score_color) else: obj = super(ScoreMatrix, sm) return obj._repr_html_() diff --git a/sciunit/scores/collections_m2m.py b/sciunit/scores/collections_m2m.py index 66180e9..98830ea 100644 --- a/sciunit/scores/collections_m2m.py +++ b/sciunit/scores/collections_m2m.py @@ -159,7 +159,7 @@ def get_group(self, x: list) -> Any: def __getattr__(self, name: str) -> Any: if name in ["score", "norm_score", "related_data"]: - attr = self.applymap(lambda x: getattr(x, name)) + attr = self.map(lambda x: getattr(x, name)) else: attr = super(ScoreMatrixM2M, self).__getattribute__(name) return attr @@ -171,4 +171,4 @@ def norm_scores(self) -> pd.DataFrame: Returns: DataFrame: A pandas DataFrame instance that contains norm scores. """ - return self.applymap(lambda x: x.norm_score) + return self.map(lambda x: x.norm_score) diff --git a/sciunit/suites.py b/sciunit/suites.py index 5d359e5..9895bea 100755 --- a/sciunit/suites.py +++ b/sciunit/suites.py @@ -40,7 +40,7 @@ def __init__( optimizer (optional): A function to bind to self.optimize (first argument must be a TestSuite). Defaults to None. """ - self.name = name if name else "Suite_%d" % random.randint(0, 1e12) + self.name = name if name else "Suite_%d" % random.randint(0, 10**12) if isinstance(tests, dict): for key, value in tests.items(): if not isinstance(value, Test): diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 61622ac..0000000 --- a/setup.cfg +++ /dev/null @@ -1,41 +0,0 @@ -[metadata] -name = sciunit -version = 0.2.8 -description = A test-driven framework for formally validating scientific models against data. -long_description = file: README.md -long_description_content_type = text/markdown -url = http://sciunit.scidash.org - -author = Rick Gerkin -author_email = rgerkin@asu.edu -license = MIT -classifiers = - License :: OSI Approved :: MIT License - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - - -[options] -zip_safe = False -packages = find: -python_requires = >=3.7 -install_requires = - bs4 - cerberus>=1.2 - deepdiff - gitpython - importlib-metadata - ipykernel - ipython - jsonpickle - lxml - matplotlib - nbconvert - nbformat - pandas>=0.18 - quantities>=0.13.0 - -[options.entry_points] -console_scripts = sciunit=sciunit.__main__:main diff --git a/setup.py b/setup.py deleted file mode 100644 index c81c42d..0000000 --- a/setup.py +++ /dev/null @@ -1,7 +0,0 @@ -import setuptools -import site -import sys - -site.ENABLE_USER_SITE = "--user" in sys.argv[1:] - -setuptools.setup()