-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add stricter version guards for NumPy #2207
Comments
I think it is going to have to be adding a lower bound to NumPy as if the lines from typing import TYPE_CHECKING
if TYPE_CHECKING:
from numpy.typing import ArrayLike, DTypeLike, NBitBase, NDArray are added to Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/venv/lib/python3.8/site-packages/pyhf/__init__.py", line 3, in <module>
from pyhf.tensor.manager import get_backend
File "/venv/lib/python3.8/site-packages/pyhf/tensor/manager.py", line 49, in <module>
_default_backend: TensorBackend = BackendRetriever.numpy_backend()
File "/venv/lib/python3.8/site-packages/pyhf/tensor/__init__.py", line 20, in __getattr__
from pyhf.tensor.numpy_backend import numpy_backend
File "/venv/lib/python3.8/site-packages/pyhf/tensor/numpy_backend.py", line 17, in <module>
T = TypeVar("T", bound=NBitBase)
NameError: name 'NBitBase' is not defined given pyhf/src/pyhf/tensor/numpy_backend.py Line 15 in 22c1699
This isn't great (but also not terrible) in the grand scheme of giving control to Lines 52 to 55 in 6e5feef
and |
You can make your TypeVar use strings ( |
Ah, yes, right again! 😄 I really need to get better at typing 😅 |
@kskovpen This is now guarded against in |
Summary
@kskovpen noted on the IRIS-HEP Slack that they were having issues with older NumPy versions and
pyhf
v0.7.1
:@agoose77 correctly noted that
numpy.typing
wasn't introduced untilnumpy
v1.21.0
which is the version thatpyhf
tests against for our lower boundspyhf/tests/constraints.txt
Line 9 in 22c1699
but that we don't explicitly enforce a lower bound as we defer to
scipy
to do that.pyhf/pyproject.toml
Lines 51 to 53 in 22c1699
Though the lowest constraints possible on
numpy
come from the lower bound onscipy
which forscipy
v1.5.1
isnumpy>=1.14.5
:though the oldest Python 3.8
numpy
with wheels isv1.17.3
and indeed this problem becomes reproducible thenand stays that way until
numpy
v1.21.0
(which again is wherenumpy.typing
got added) is usedSo this
pyhf/src/pyhf/tensor/numpy_backend.py
Line 8 in 22c1699
should be guarded against more.
@agoose77 has suggested
OS / Environment
Steps to Reproduce
File Upload (optional)
No response
Expected Results
For
pyhf
to properly enforce lower bounds.Actual Results
pyhf
allows for installation ofnumpy
versions beforenumpy.typing
was introduced.pyhf Version
pyhf, version 0.7.1
Code of Conduct
The text was updated successfully, but these errors were encountered: