-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ENH,WIP: Adding "casting" keyword to close and equal functions in numeric (fix #17136) #18950
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
base: main
Are you sure you want to change the base?
Conversation
…efault casting rule is unsafe.
@lschwetlick Lint is unhappy.
|
Yup, thanks for putting it on my radar :) We are still discussing other stuff that needs doing in this Issue thread #17136 . I'll work on it in the next few days! |
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.
I've got a couple of comments that apply to all functions changed within this PR.
Secondly, the annotation of the respective functions will have to be updated in the stub file: https://github.com/numpy/numpy/blob/main/numpy/core/numeric.pyi
By the looks of it something like this should suffice:
from numpy import _Casting # A string-`Literal` containing all valid casting kinds
def isclose(
a: ArrayLike,
b: ArrayLike,
rtol: float = ...,
atol: float = ...,
equal_nan: bool = ...,
casting: _Casting = ..., # The new keyword
) -> Any: ...
Co-authored-by: Bas van Beek <43369155+BvB93@users.noreply.github.com>
Co-authored-by: Bas van Beek <43369155+BvB93@users.noreply.github.com>
Co-authored-by: Bas van Beek <43369155+BvB93@users.noreply.github.com>
As discussed in #17136 , the functions
currently implicitly cast between data types without warning or error. Eg.:
In this PR we add the "casting" keyword to specify at which level inputs should be cast in the comparison. For example: