-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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: Replace find_common_types #16398
Conversation
73baffe
to
543ebc6
Compare
@@ -155,7 +155,7 @@ def _nbool_correspond_all(u, v, w=None): | |||
ntf = (u & not_v).sum() | |||
ntt = (u & v).sum() | |||
else: | |||
dtype = np.find_common_type([int], [u.dtype, v.dtype]) | |||
dtype = np.result_type(int, u.dtype, v.dtype) |
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.
In theory, this can change the result in some cases, but in practice I can't think of a way to make it fail when the first part is [int]
...
(in that case u.dtype == longdouble
is honored. A change would happen there if the first part was a float/complex, where the longdouble would then be ignored.)
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.
scipy.sparse changes look fine
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.
LGTM, we have some approvals and CI is happy. In it goes. Thank you @eendebakpt et al.!
What does this implement/fix?
The
np.find_common_type
method is deprecated within numpy. See numpy/numpy#21703 and numpy/numpy#21742.This PR was triggered because
np.find_common_type
is one of performance bottlenecks inside thescipy.stats.rv_continuous
.This PR replaces the
np.find_common_type
withnp.results_type
ornp.promote_type
. These alternatives are both faster and maintained.Additional information
Microbenchmark results