diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8e94939b..528155b9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,49 +32,35 @@ jobs: - ubuntu-latest python-version: - "3.9" - - "3.10" - - "3.11" - "3.12" + - "3.13" include: - os: windows-latest python-version: "3.9" - os: macos-13 python-version: "3.9" - - os: macos-14 + - os: macos-latest python-version: "3.12" # old versions not supported name: Check Python ${{ matrix.python-version }} ${{ matrix.os }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Setup Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Get pip cache dir - id: pip-cache - run: | - echo "::set-output name=dir::$(pip cache dir)" - - name: pip cache - uses: actions/cache@v4.1.2 - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg') }}-pip-${{ hashFiles('**/setup.py') }}-pip-${{ hashFiles('**/pyproject.toml') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Install package run: | - python -m pip install --upgrade pip - python -m pip install -e .[test] pytest-xdist # for multiprocessing + pip install uv + uv pip install --system -e .[test] pytest-xdist # for multiprocessing, -e needed for pathes etc. - name: Test package run: python -m pytest --doctest-modules --cov=hepstats --cov-report=xml -n auto - name: Upload coverage to Codecov - if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest' + if: matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest' uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} # technically not needed, but prevents failures: https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954 @@ -106,13 +92,16 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v5 + + - name: Setup Python 3.9 + uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: 3.9 + - name: Install dependencies run: | - pip install -U -q -e .[docs] - pip list + pip install uv + uv pip install --system -e .[docs] - name: build docs run: | sphinx-build -b html docs docs/_build/html diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fed9f1e8..a44b54e7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,16 +19,16 @@ repos: - id: requirements-txt-fixer - id: debug-statements - id: end-of-file-fixer - - repo: https://github.com/mgedmin/check-manifest - rev: "0.50" - hooks: - - id: check-manifest - args: - - --update - - --no-build-isolation - additional_dependencies: - - hatchling - - hatch-vcs +# - repo: https://github.com/mgedmin/check-manifest +# rev: "0.50" +# hooks: +# - id: check-manifest +# args: +# - --update +# - --no-build-isolation +# additional_dependencies: +# - hatchling +# - hatch-vcs - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.12.0 @@ -60,7 +60,7 @@ repos: rev: v2.7.0 hooks: - id: setup-cfg-fmt - args: [ --max-py-version=3.12, --include-version-classifiers ] + args: [ --max-py-version=3.13, --include-version-classifiers ] # Notebook formatting - repo: https://github.com/nbQA-dev/nbQA diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1d10f316..9d2d11ba 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,8 @@ Changelog main ************** +* Add support for Python 3.13 + Version 0.8.1 ************** diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 3f22b4ff..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,24 +0,0 @@ -graft docs -prune docs/_build -graft src -graft tests -graft notebooks - -global-exclude .env* -global-exclude .git* -global-exclude .pytest_cache -global-exclude .DS_Store -global-exclude .ipynb_checkpoints -global-exclude *-checkpoint.ipynb -global-exclude *-checkpoint.py -global-exclude *.py[co] -global-exclude __pycache__ - -prune .ci -prune .github - -include README.md pyproject.toml setup.py setup.cfg -include *.yaml -include *.yml -recursive-include LICENSES * -include CHANGELOG.rst diff --git a/pyproject.toml b/pyproject.toml index af71286b..c80c96a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,7 +68,8 @@ test = [ "pytest", "pytest-cov", "pytest-runner", - "zfit>=0.20.0", + "zfit>=0.20.0;python_version<'3.13'", +# 'hepstats[zfit];python_version<"3.13"', # not working, why? ] zfit = ["zfit>=0.20.0"] diff --git a/tests/conftest.py b/tests/conftest.py index 81440b93..f1980a58 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -32,7 +32,11 @@ def data_gen(): # TODO: manually ported, use pre-made: https://github.com/zfit/zfit-development/issues/73 @pytest.fixture(autouse=True) def _setup_teardown(): - import zfit + try: + import zfit + except ImportError: + yield + return old_chunksize = zfit.run.chunking.max_n_points old_active = zfit.run.chunking.active diff --git a/tests/hypotests/test_basetest.py b/tests/hypotests/test_basetest.py index 2b28a8fc..b2053f74 100644 --- a/tests/hypotests/test_basetest.py +++ b/tests/hypotests/test_basetest.py @@ -1,6 +1,6 @@ import pytest import numpy as np -import zfit +zfit = pytest.importorskip("zfit") from zfit.loss import UnbinnedNLL from zfit.minimize import Minuit @@ -9,6 +9,7 @@ from hepstats.hypotests.parameters import POI, POIarray + def create_loss(): obs = zfit.Space("x", limits=(0.1, 2.0)) data = zfit.data.Data.from_numpy(obs=obs, array=np.random.normal(1.2, 0.1, 10000)) diff --git a/tests/hypotests/test_calculators.py b/tests/hypotests/test_calculators.py index 111bad55..35bd25a7 100644 --- a/tests/hypotests/test_calculators.py +++ b/tests/hypotests/test_calculators.py @@ -2,7 +2,7 @@ import numpy as np import pytest -import zfit +zfit = pytest.importorskip("zfit") from zfit.loss import UnbinnedNLL from zfit.minimize import Minuit diff --git a/tests/hypotests/test_confidence_intervals.py b/tests/hypotests/test_confidence_intervals.py index e99d3d14..e2c02b3c 100644 --- a/tests/hypotests/test_confidence_intervals.py +++ b/tests/hypotests/test_confidence_intervals.py @@ -1,6 +1,6 @@ import pytest import numpy as np -import zfit +zfit = pytest.importorskip("zfit") import os from zfit.loss import UnbinnedNLL from zfit.minimize import Minuit diff --git a/tests/hypotests/test_discovery.py b/tests/hypotests/test_discovery.py index 75eb861e..39c2f171 100644 --- a/tests/hypotests/test_discovery.py +++ b/tests/hypotests/test_discovery.py @@ -2,7 +2,7 @@ import numpy as np import pytest -import zfit +zfit = pytest.importorskip("zfit") from zfit.loss import UnbinnedNLL from zfit.minimize import Minuit diff --git a/tests/hypotests/test_parameters.py b/tests/hypotests/test_parameters.py index 20af9974..b24aa884 100644 --- a/tests/hypotests/test_parameters.py +++ b/tests/hypotests/test_parameters.py @@ -1,7 +1,7 @@ #!/usr/bin/python import pytest import numpy as np -import zfit +zfit = pytest.importorskip("zfit") from hepstats.hypotests.parameters import POI, POIarray diff --git a/tests/hypotests/test_toysutils.py b/tests/hypotests/test_toysutils.py index 21b82140..6fd0b8b7 100644 --- a/tests/hypotests/test_toysutils.py +++ b/tests/hypotests/test_toysutils.py @@ -1,6 +1,6 @@ import pytest import numpy as np -import zfit +zfit = pytest.importorskip("zfit") import os from zfit.loss import ExtendedUnbinnedNLL, UnbinnedNLL from zfit.minimize import Minuit diff --git a/tests/hypotests/test_upperlimit.py b/tests/hypotests/test_upperlimit.py index 4865ecc6..45755206 100644 --- a/tests/hypotests/test_upperlimit.py +++ b/tests/hypotests/test_upperlimit.py @@ -1,6 +1,7 @@ import pytest import numpy as np import os +zfit = pytest.importorskip("zfit") from zfit.minimize import Minuit import hepstats diff --git a/tests/modeling/test_bayesianblocks.py b/tests/modeling/test_bayesianblocks.py index 2346cdd6..3cb23fa3 100644 --- a/tests/modeling/test_bayesianblocks.py +++ b/tests/modeling/test_bayesianblocks.py @@ -1,9 +1,11 @@ -import os +from pathlib import Path + import numpy as np + import hepstats from hepstats.modeling import bayesian_blocks -answer_dir = os.path.dirname(hepstats.__file__) + "/../../tests/modeling/data" +answer_dir = Path(__file__).parent / "data" def test_bayesian_blocks(cmdopt, data_gen): @@ -12,10 +14,10 @@ def test_bayesian_blocks(cmdopt, data_gen): be3 = bayesian_blocks(data_gen[0], weights=data_gen[2]) if cmdopt == "generate": - with open(answer_dir + "/answers_bayesian_blocks.npz", "wb") as f: + with open(answer_dir / "answers_bayesian_blocks.npz", "wb") as f: np.savez(f, be1=be1, be2=be2, be3=be3) elif cmdopt == "test": - answers = np.load(answer_dir + "/answers_bayesian_blocks.npz") + answers = np.load(answer_dir / "answers_bayesian_blocks.npz") assert np.all(be1 == answers["be1"]) assert np.all(be2 == answers["be2"]) assert np.all(be3 == answers["be3"]) diff --git a/tests/splots/test_splots.py b/tests/splots/test_splots.py index 459429ec..051b89dc 100644 --- a/tests/splots/test_splots.py +++ b/tests/splots/test_splots.py @@ -2,7 +2,7 @@ import pytest from scipy.stats import ks_2samp -import zfit +zfit = pytest.importorskip("zfit") from zfit.loss import ExtendedUnbinnedNLL from zfit.minimize import Minuit