Skip to content

Commit

Permalink
test: make zfit optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-eschle committed Nov 9, 2024
1 parent b18b218 commit c9b6d58
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 14 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ jobs:
- ubuntu-latest
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
include:
- os: windows-latest
python-version: "3.9"
Expand All @@ -47,6 +46,8 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
Expand All @@ -67,14 +68,14 @@ jobs:
- name: Install package
run: |
python -m pip install --upgrade pip
python -m pip install -e .[test] pytest-xdist # for multiprocessing
uv pip install --upgrade pip
uv pip install -e .[test] pytest-xdist # for multiprocessing
- 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
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
main
**************

* Add support for Python 3.13

Version 0.8.1
**************

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ test = [
"pytest",
"pytest-cov",
"pytest-runner",
"zfit>=0.20.0",
'hepstats[zfit];python_version<"3.13"',
]
zfit = ["zfit>=0.20.0"]

Expand Down
3 changes: 2 additions & 1 deletion tests/hypotests/test_basetest.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion tests/hypotests/test_calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/hypotests/test_confidence_intervals.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/hypotests/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/hypotests/test_parameters.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/hypotests/test_toysutils.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/hypotests/test_upperlimit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import numpy as np
import os
zfit = pytest.importorskip("zfit")
from zfit.minimize import Minuit

import hepstats
Expand Down
2 changes: 1 addition & 1 deletion tests/splots/test_splots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c9b6d58

Please sign in to comment.