Skip to content
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

Silence numpy2 warning, fix failing tests, and lack of integration of doctests #24

Closed

Conversation

David-McKenna
Copy link
Contributor

With the release of numpy 2.0, np.linalg.linalg has been depricated[0], and it's use in the module was raising warnings. This MR changes the linalg.norm import to use the parent linalg module to remove the warning.

Tests were broken, so I fixed them (and integrated the doctests into the pytest config) too.

[0] https://numpy.org/doc/stable/release/2.0.0-notes.html#numpy-linalg-linalg-made-private

…warning present in numpy 2.0 following the deprecation of the module.\nhttps://numpy.org/doc/stable/release/2.0.0-notes.html\#numpy-linalg-linalg-made-private
With the release of numpy 2.0, np.linalg.linalg has been depricated[0], and it's use in the module was raising warnings. This MR changes the linalg.norm import to use the parent linalg module to remove the warning.

Tests were broken, so I fixed them (and integrated the doctests into the pytest config) too.

[0] https://numpy.org/doc/stable/release/2.0.0-notes.html#numpy-linalg-linalg-made-private
@David-McKenna
Copy link
Contributor Author

Tests on 3.9+ seem to be failing as numpy floats are being printed in a numpy.float(value) format, but I can't replicate it locally on 3.12, numpy 1.26.4:

> pytest
============================= test session starts ==============================
platform darwin -- Python 3.12.2, pytest-8.1.1, pluggy-1.4.0
rootdir: /Users/mckenna/git/lofar-antenna-positions
configfile: pyproject.toml
plugins: cov-5.0.0, typeguard-2.13.3, anyio-4.4.0, jaxtyping-0.2.33
collected 21 items

src/lofarantpos/db.py .....                                              [ 23%]
src/lofarantpos/geo.py .......                                           [ 57%]
src/lofarantpos/plotutil.py .......                                      [ 90%]
test/test_db.py .                                                        [ 95%]
test/test_geo.py .                                                       [100%]

============================== 21 passed in 2.60s ==============================

Checking numpy.set_printoptions, the only way to work around this might be to set a custom formatter for floats. Not sure what you'd desire the target here to be.

@tammojan
Copy link
Contributor

tammojan commented Sep 9, 2024

Shall I merge this PR with its major fix (the linalg), and work on formatting pytest output in a new one?

@David-McKenna
Copy link
Contributor Author

David-McKenna commented Sep 9, 2024 via email

@tammojan
Copy link
Contributor

tammojan commented Sep 9, 2024

Your branch had quite some merge conflicts with the main branch, so I committed the numpy 2.0 directly (04a3a0c), and made another MR for making the tests pass: #25

@tammojan tammojan closed this Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants