-
Notifications
You must be signed in to change notification settings - Fork 28
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
RCAL-913 Resolve numpy 2 issues #1447
RCAL-913 Resolve numpy 2 issues #1447
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1447 +/- ##
==========================================
+ Coverage 78.09% 78.11% +0.01%
==========================================
Files 119 119
Lines 7744 7744
==========================================
+ Hits 6048 6049 +1
+ Misses 1696 1695 -1
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. |
That looks good. Could you say a word or two about needing to change the cross products from 2-vectors to 3-vectors? Did numpy 2 just remove 2D cross products? Thanks! |
1569b46
to
f9d29b3
Compare
It is marked as deprecated, and generates ~192000 warnings. It is depreciated as part of the lead into numpy 2 being fully python array API compliant, see numpy/numpy#24818. Cross products themselves are not really defined for products of 2D vectors in general; hence, the removal. In reality, this is just a shorthand for computing the determinant of the matrix made with the two vector. This is what the update should really be doing. |
d2eee43
to
f05c271
Compare
image.meta.background.level = sky | ||
# In numpy 2, the dtypes are more carefully controlled, so to match the | ||
# schema the data type needs to be re-cast to float64. | ||
image.meta.background.level = sky.astype(np.float64) |
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.
The tighter adherence to dtypes
means that this number should have been a float32
before, but that violates the schemas: https://github.com/spacetelescope/rad/blob/b61c261deb1e21e13401e480a9790c6a212a0861/src/rad/resources/schemas/sky_background-1.0.0.yaml#L17. Should those be updated?
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.
It's certainly the case that f32 is enough precision here. If we can update the schema without needing to do more than okify, then it probably makes most sense to update the rad schema to f32. But 4 bytes either way isn't a big deal, so if it's harder than running 'okify' then we should probably do the cast as you show here.
f05c271
to
6828d4a
Compare
…ved accuracy and to address deprecation of 2D cross product
c05d7aa
to
36a2644
Compare
These changes do not effect the regression tests when run with numpy 1, but the regression tests have slightly different results when run with numpy 2. |
This looks good to me. FWIW, I inspected the regtests and they don't vary by more than a part in 10^8 or so for the small values; the rare large reported fractional differences are due to zeros becoming 10^-8s. I did not actually try to figure out those differences---they're a little weird in that they affect only the pipeline regtests---but they are scientifically unimportant. |
Resolves RCAL-913
Closes #1413
This PR together with spacetelescope/stcal#305 (already merged) resolves all the issues from numpy 2 detected by the unit tests.
Note, I need to run the regression tests to confirm I caught all the issues.
Tasks
24Q4_B15
(use the latest build if not sure)no-changelog-entry-needed
)changes/
:echo "changed something" > changes/<PR#>.<changetype>.rst
(see below for change types)docs/
pageokify_regtests
to update the truth filesnews fragment change types...
changes/<PR#>.general.rst
: infrastructure or miscellaneous changechanges/<PR#>.docs.rst
changes/<PR#>.stpipe.rst
changes/<PR#>.associations.rst
changes/<PR#>.scripts.rst
changes/<PR#>.mosaic_pipeline.rst
changes/<PR#>.patch_match.rst
steps
changes/<PR#>.dq_init.rst
changes/<PR#>.saturation.rst
changes/<PR#>.refpix.rst
changes/<PR#>.linearity.rst
changes/<PR#>.dark_current.rst
changes/<PR#>.jump_detection.rst
changes/<PR#>.ramp_fitting.rst
changes/<PR#>.assign_wcs.rst
changes/<PR#>.flatfield.rst
changes/<PR#>.photom.rst
changes/<PR#>.flux.rst
changes/<PR#>.source_detection.rst
changes/<PR#>.tweakreg.rst
changes/<PR#>.skymatch.rst
changes/<PR#>.outlier_detection.rst
changes/<PR#>.resample.rst
changes/<PR#>.source_catalog.rst