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

Numpy Deprecation Warnings #364

Open
Witchblade101 opened this issue Feb 13, 2025 · 8 comments
Open

Numpy Deprecation Warnings #364

Witchblade101 opened this issue Feb 13, 2025 · 8 comments
Assignees

Comments

@Witchblade101
Copy link
Collaborator

Running generate_nircam.py I got the following warnings:

/Users/dlong/pysiaf/generate/generate_nircam.py:209: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.) v2_offset = float( /Users/dlong/pysiaf/generate/generate_nircam.py:212: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.) v3_offset = float(

I suspect we'll see the same in all of the generate scripts, and others. This was fixed in many of our routines as part of #360. This issue is to find and fix it everywhere else.

@mfixstsci
Copy link
Collaborator

@Witchblade101 I am curious if this is the reason that Paul made the changes in #363. Not this same warning, but a numpy deprecation in general. I would like to see us upgrade to Numpy >=2.0 but I don't know if that's possible right now.

@Witchblade101
Copy link
Collaborator Author

I believe those are the changes from Brett that we accepted back in the fall. We merged them into Main, but not into siaf-updates. They got pulled into my fork when I created a branch for Paul's changes.
I'm sure the numpy-related changes were to correct the deprecation warnings he was getting.

@Witchblade101
Copy link
Collaborator Author

I'm going to follow the advice of https://numpy.org/devdocs/numpy_2_0_migration_guide.html and try running the recommended Ruff linting rule on a local branch of our code, then run the tests and generate scripts and see what kind of warnings I get, and if everything still looks OK otherwise.

@mfixstsci
Copy link
Collaborator

@Witchblade101 that sounds good to me. Let me know if you need any help testing the migration to numpy 2.0

@Witchblade101
Copy link
Collaborator Author

The first check after adding

[tool.ruff.lint]
select = ["NPY201"]

to pyproject.toml in a clone of the current Main branch:

(pysiaf-lint) dlong@hikaru pysiaf % ruff check
All checks passed!

@Witchblade101
Copy link
Collaborator Author

I tried the same thing on a branch made from siaf-updates, but it also found no errors. So as a check of the tool I added

[tool.ruff.lint] select = [ "NPY201", # pycodestyle "E", # Pyflakes "F", # pyupgrade "UP", # flake8-bugbear "B", # flake8-simplify "SIM", # isort "I" ]

and that gave

Found 1799 errors.
[*] 521 fixable with the --fix option (169 hidden fixes can be enabled with the --unsafe-fixes option).

so the linter is catching things

@mfixstsci
Copy link
Collaborator

@Witchblade101 that's good! As for the package having linting issues, woof. Might be a task for another time.

@Witchblade101
Copy link
Collaborator Author

I set the linting to be very aggressive, on purpose, just to see if I had it configured correctly.

Next I want to check if it only flags errors, or catches warnings, as well. What we were seeing were deprecation warnings, and those may be getting ignored by default.

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

No branches or pull requests

2 participants