-
-
Notifications
You must be signed in to change notification settings - Fork 11k
ENH: call np.positive in ndarray.__pos__, and issue a deprecation warning when it falls #9081
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
Comments
I think you also want |
In fact, that could potentially replace the if self.__array_ufunc__ is not ndarray.__array_ufunc__:
return np.positive(self)
else:
return self.copy() I don't think we'd even need to deprecate anything if we did it this way. |
Difference would be that |
Or more precisely, |
I also wanted to deprecate calls like But we could switch to only catching def __pos__(self):
if self.__array_ufunc__ is not ndarray.__array_ufunc__:
return np.positive(self)
else:
try:
return np.positive(self)
except TypeError:
issue deprecation warning
return self.copy() This would give us a path to eventually replacing the implementation with: def __pos__(self):
return np.positive(self) |
I'll just say that it would be really nice if |
@ngoldbaum: Although it's also really not hard for you to use |
I realize, it's just yet another corner case that an implementer of an ndarray subclass needs to deal with. |
@ngoldbaum this logic is all pretty self-contained (I would start here), so implementing something like @njsmith's suggestion both would be straightforward. Contributions would certainly be welcome! It would indeed be nice to get this into 1.13 before the final release. |
See #11450 for a fix. |
As I wrote in #8967 (comment):
This will be useful for ndarray subclasses that override
__array_ufunc__
.The text was updated successfully, but these errors were encountered: