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

Fix WCSAxes sometimes emitting RuntimeWarning with NumPy 1.24 #14211

Merged
merged 3 commits into from Dec 24, 2022

Conversation

ayshih
Copy link
Contributor

@ayshih ayshih commented Dec 21, 2022

As of NumPy 1.24 (specifically, numpy/numpy#21437), casting a NaN to an integer produces a RuntimeWarning. astropy.visualization.wcsaxes.coordinate_range.find_coordinate_range() uses .astype(int) to truncate an array to integers, but the array can have NaNs because it is the result of a transformation to world coordinates. Not only does that produce a RuntimeWarning, the resulting array has garbage integers where the NaNs were, which is silly because the array is immediately turned back into a float array.

This PR replaces those uses with np.trunc().

@github-actions

This comment was marked as outdated.

@ayshih ayshih force-pushed the trunc branch 2 times, most recently from fbf154e to f7c8289 Compare December 22, 2022 17:02
@ayshih ayshih marked this pull request as ready for review December 22, 2022 18:27
@pllim pllim added this to the v5.0.6 milestone Dec 23, 2022
@pllim pllim added Bug 💤 backport-v5.0.x on-merge: backport to v5.0.x 💤 backport-v5.2.x on-merge: backport to v5.2.x labels Dec 23, 2022
@pllim
Copy link
Member

pllim commented Dec 23, 2022

Since this actually fixes something, I think we need a change log. Can you please add one? Thanks!

Copy link
Member

@Cadair Cadair left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@pllim
Copy link
Member

pllim commented Dec 23, 2022

Change log aside, a rebase would also get rid of the failures. Thanks!

@ayshih
Copy link
Contributor Author

ayshih commented Dec 24, 2022

Changelog added, and rebased

@pllim pllim merged commit 9ee4a46 into astropy:main Dec 24, 2022
@lumberbot-app

This comment was marked as resolved.

@pllim

This comment was marked as resolved.

pllim added a commit that referenced this pull request Dec 24, 2022
…211-on-v5.2.x

Backport PR #14211 on branch v5.2.x (Fix WCSAxes sometimes emitting RuntimeWarning with NumPy 1.24)
pllim added a commit to pllim/astropy that referenced this pull request Dec 27, 2022
Merge pull request astropy#14211 from ayshih/trunc

Fix WCSAxes sometimes emitting RuntimeWarning with NumPy 1.24

(cherry picked from commit 9ee4a46)
@pllim
Copy link
Member

pllim commented Dec 27, 2022

Manual backport to v5.0.x at #14234

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug visualization.wcsaxes 💤 backport-v5.0.x on-merge: backport to v5.0.x 💤 backport-v5.2.x on-merge: backport to v5.2.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants