-
Notifications
You must be signed in to change notification settings - Fork 587
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
compatibility with numpy>=2.0
#3955
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @keewis! Both the implementation and the test changes look good to me. The CI setup is a little tricky, but we can imitate the "oldest numpy" job:
- set up a tox environment, like below, with this install command:
hypothesis/hypothesis-python/tox.ini
Lines 46 to 56 in 5578efc
# This test job runs on the oldest version of CPython we support, against the minimum # version specified in our runtime dependencies. For now, that's the oldest version # with a wheel for non-EOL Python. In future we might deprecate faster per NEP-29. [testenv:py38-oldestnumpy] deps= -r../requirements/test.txt allowlist_externals = bash commands= bash -c "pip install --only-binary=:all: numpy==$(grep 'numpy>=' setup.py | grep -oE '[0-9.]+')" python -bb -X dev -m pytest tests/numpy/ -n auto - re-export that for our tooling (no need for the
py=
argument in this case):standard_tox_task("py38-oldestnumpy", py="3.8") - invoke it for GH actions:
hypothesis/.github/workflows/main.yml
Line 79 in 5578efc
- check-py38-oldestnumpy
and then I think we're done 🙂
Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
woohoo, some Numpy-2-specific CI failures!
|
I've seen a lot more than these locally, but maybe those are not running because of the environment? Edit: nope, that was because I copied the Most notably, some File ".../hypothesis/hypothesis-python/tests/ghostwriter/test_expected_output.py", line 132, in <module>
("magic_gufunc", ghostwriter.magic(numpy.matmul)),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../hypothesis/hypothesis-python/src/hypothesis/extra/ghostwriter.py", line 1301, in magic
make_(_make_ufunc_body, func, annotate=annotate)
File ".../hypothesis/hypothesis-python/src/hypothesis/extra/ghostwriter.py", line 1202, in make_
imp, body = how(*args, **kwargs, except_=except_, style=style)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../hypothesis/hypothesis-python/src/hypothesis/extra/ghostwriter.py", line 1884, in _make_ufunc_body
call=_write_call(func, *ascii_lowercase[: func.nin], except_=except_),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../hypothesis/hypothesis-python/src/hypothesis/extra/ghostwriter.py", line 781, in _write_call
args = ", ".join(
^^^^^^^^^^
File ".../hypothesis/hypothesis-python/src/hypothesis/extra/ghostwriter.py", line 784, in <genexpr>
if p.kind is inspect.Parameter.POSITIONAL_ONLY
^^^^^^
AttributeError: 'NoneType' object has no attribute 'kind' and (after commenting out the first one): File ".../hypothesis/hypothesis-python/tests/ghostwriter/test_expected_output.py", line 191, in <module>
("addition_op_multimagic", ghostwriter.magic(add, operator.add, numpy.add)),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../hypothesis/hypothesis-python/src/hypothesis/extra/ghostwriter.py", line 1301, in magic
make_(_make_ufunc_body, func, annotate=annotate)
File ".../hypothesis/hypothesis-python/src/hypothesis/extra/ghostwriter.py", line 1202, in make_
imp, body = how(*args, **kwargs, except_=except_, style=style)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../hypothesis/hypothesis-python/src/hypothesis/extra/ghostwriter.py", line 1884, in _make_ufunc_body
call=_write_call(func, *ascii_lowercase[: func.nin], except_=except_),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../hypothesis/hypothesis-python/src/hypothesis/extra/ghostwriter.py", line 781, in _write_call
args = ", ".join(
^^^^^^^^^^
File ".../hypothesis/hypothesis-python/src/hypothesis/extra/ghostwriter.py", line 784, in <genexpr>
if p.kind is inspect.Parameter.POSITIONAL_ONLY
^^^^^^
AttributeError: 'NoneType' object has no attribute 'kind' Also, there appears to be an issue with your formatting checks, it complains that |
in the most recent commit I removed the limitation to just |
here, I guess we need
Ah, for that copy the "niche" tests - that covers everything with optional dependencies. (and thanks for pursuing this!) |
Not sure if that can work, in |
It appears the error only occurs on |
the final failure on In the most recent commits I've hacked together a wrapping mechanism that allows removing arbitrary attributes on the array returned by any of the functions in the namespace (I don't know if that also works on properties, though), which can then be used to patch out the Edit: not sure what to make of the windows 3.9 cover+rest CI failure... it says "stack overflow", but the traceback looks like a recursion, which is weird. To make sure it's not the issue, we could explicitly call |
Hmm. Might as well try this - it's certainly suspicious that we hit this with mocks around. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny nits, not necessary to merge
hypothesis-python/src/hypothesis/strategies/_internal/strategies.py
Outdated
Show resolved
Hide resolved
Didn't help, see the most recent commit. So I don't know what's wrong here. |
finfo.smallest_normal
to builtin python float
numpy>=2.0
Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
my last attempt, replacing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @keewis! Delighted to see this all working 🙂
This also replaces a couple of top-level
pytest.warns
with ignores, which was the simplest way I found to silence the errors caused by the change in behavior ofnumpy>=2
.Still missing: a way to actually test this with a nightly build of
numpy
, but since I don't know your CI well enough I'll need help with that.With
numpy>=2
, I'm getting a bunch of other failures locally, mostly concerning the removal ofnumpy.asfarray
.