Cast mask to data dtype in create_deviation for strict array API - #972
Merged
Conversation
``create_deviation(..., disregard_nan=True)`` multiplied a float array by a boolean mask. array-api-strict (and the Array API standard) only allow arithmetic between numeric dtypes, so this raised ``TypeError``. Cast the inverted mask to the data dtype first. The double-sqrt NaN trick that follows is unchanged. ``test_create_deviation_from_negative_2`` used the same idiom and also added a ``numpy.float64`` scalar to a strict array; cast both explicitly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DTN9DnPnLKK2u7knnMJ2gA
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #972 +/- ##
=======================================
Coverage 95.83% 95.83%
=======================================
Files 8 8
Lines 1631 1631
=======================================
Hits 1563 1563
Misses 68 68 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
pre-commit.ci has been failing on main since the black 26.5.1 bump in astropy#919 because black now requires a blank line after the module docstring in ccdproc/__init__.py. This is the only formatting change it wants. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DTN9DnPnLKK2u7knnMJ2gA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
create_deviation(..., disregard_nan=True)multiplied a float array by a boolean mask (data * ~mask). The Array API standard only allows arithmetic between numeric dtypes, so array-api-strict raisedTypeError: Only numeric dtypes are allowed in __mul__. This casts the inverted mask to the data dtype first; the double-sqrt NaN trick that follows is unchanged.test_create_deviation_from_negative_2used the same idiom and also added anumpy.float64scalar to a strict array, so the test is adjusted the same way. Nobackend_xfailmarkers existed on the create_deviation tests, so none needed removing.Test matrix
pytest ccdprocJAX_ENABLE_X64=True)CCDPROC_LOG_ARRAY_ESCAPES=1 CCDPROC_ENFORCE_ESCAPE_BASELINE=1ccdproc/tests/test_ccdproc.pyunder array-api-strict: 32 failed / 31 passed / 10 xfailed before, 31 failed / 32 passed / 10 xfailed after. All 11create_deviationtests pass under strict.Fixes #968
🤖 Generated with Claude Code
https://claude.ai/code/session_01DTN9DnPnLKK2u7knnMJ2gA