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

JP-3664: Numpy 2.0 exposed implicit type promotion #319

Merged
merged 2 commits into from
Sep 13, 2024

Conversation

tapastro
Copy link
Collaborator

@tapastro tapastro commented Aug 21, 2024

Partially addresses JP-3664

Closes jwst/#8578
Partially addresses jwst/#8580

This PR addresses a bug exposed by testing numpy 2.0 - the irs2 datamodel specifies arrays to be of type uint8, but operations in refpix promoted them to uint16 implicitly in numpy<2.0. Numpy 2.0 does not implicitly type promote in this case, leading to an integer overflow. This PR updates the specified array datatype to uint16.

Checklist

  • added entry in CHANGES.rst (either in Bug Fixes or Changes to API)
  • updated relevant tests
  • updated relevant documentation
  • updated relevant milestone(s)
  • added relevant label(s)

@tapastro tapastro requested a review from a team as a code owner August 21, 2024 18:35
Copy link

codecov bot commented Aug 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.18%. Comparing base (84279cf) to head (55ce7e8).
Report is 68 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #319   +/-   ##
=======================================
  Coverage   66.18%   66.18%           
=======================================
  Files         100      100           
  Lines        5397     5397           
=======================================
  Hits         3572     3572           
  Misses       1825     1825           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@braingram braingram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The changes look good to me (although a regtest run to be safe seems worthwhile).

I tested saving an irs2 model (with uint8 for OUTPUT and ODD_EVEN) and loading with the new schema. The data is safely cast to uint16 on load (in numpy <2 and 2.1).

@braingram
Copy link
Collaborator

I also suggest we leave spacetelescope/jwst#8580 open as this PR doesn't fully address all the numpy 2.0 issues with jwst.

@tapastro
Copy link
Collaborator Author

Agreed on keeping the issue open, and I'll get a regtest run soon. I have an stcal PR out as well, and I suppose I'll need a JWST PR to get the numpy upper limit out of the way.

@tapastro
Copy link
Collaborator Author

tapastro commented Aug 26, 2024

Started a regression test run here:

EDIT: make that https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/1674/

@tapastro tapastro force-pushed the numpy2-type-issue-irs2 branch from 71befb9 to e3b53d6 Compare September 6, 2024 16:43
@tapastro
Copy link
Collaborator Author

tapastro commented Sep 6, 2024

Last set of regtests were failing due to a day of Jenkins issues. Started a new set against jwst/master to check for compatibility issues with numpy<2: https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/1691/

@tapastro tapastro force-pushed the numpy2-type-issue-irs2 branch from e3b53d6 to 55ce7e8 Compare September 13, 2024 15:36
@tapastro tapastro merged commit 738e14c into spacetelescope:main Sep 13, 2024
21 checks passed
@tapastro tapastro deleted the numpy2-type-issue-irs2 branch September 13, 2024 16:00
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.

Refpix output array math incompatible with numpy 2.0
2 participants