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

MAINT: *sctype* replace NumPy 2.0 #18841

Merged
merged 1 commit into from Jul 8, 2023

Conversation

tylerjereddy
Copy link
Contributor

[skip circle]

* replace `*sctype*` NumPy usage per
numpy/numpy#23999
and NEP52 in preparation for NumPy 2.0

* there seem to be straightforward replacements
that still pass the testsuite in all cases

* `git grep -E -i "sctype"` is clean on this branch
(only present in comments for clarity where needed)

* there may be better canonical ways to do some
of these things in the future, though considerable
confusion remains per numpy/numpy#17325

* `UMFPACK`-related changes were not tested locally
(wasn't particularly friendly for PyPI-based setup/venv)

[skip circle]
Copy link
Member

@ev-br ev-br left a comment

Choose a reason for hiding this comment

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

LGTM modulo a non-blocking question.

@@ -165,7 +165,7 @@ def _copy_array_if_base_present(a):
"""
if a.base is not None:
return a.copy()
elif np.issubsctype(a, np.float32):
elif issubclass(a.dtype.type, np.float32):
Copy link
Member

Choose a reason for hiding this comment

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

Is this now a canonic NumPy way of checking if an array is single-precision? In the same like, is the way to check if an array is floating-point (as opposed to integer or complex), issubclass(a.dtype.type, np.floating)?

Asking because there is also np.issubdtype --- would be great to actually know what's the preferred way now that numpy 2.0 is on the horizon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, not sure, but I think folks smarter than I debate this type of stuff in the issue I linked?

Copy link
Member

Choose a reason for hiding this comment

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

Ah indeed. Reading comprehension issue on my side, sorry about that!

Agreed, let the bright minds of numpy converge to something, we'll happily follow. The current spelling is certainly better than issubsctype, so +1 from me.
(I probably could have a tiny preference for np.issubdtype but it's not worth the churn).

@ev-br
Copy link
Member

ev-br commented Jul 8, 2023

CI is happy, changes LGTM. Thanks Tyler, in it goes.

@ev-br ev-br merged commit ad1e339 into scipy:main Jul 8, 2023
24 checks passed
@tylerjereddy tylerjereddy deleted the treddy_numpy2_prep_sctype branch July 8, 2023 16:20
@ev-br ev-br added this to the 1.12.0 milestone Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants