-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add clip
#482
Comments
gh-187 says |
This wasn't too bad actually, a lot of it was segfaults and whether it was a ufunc or not. The relevant ones:
And of course we need to choose keyword names, always a hard problem. Existing signatures don't match:
No name is ideal - def clip(x, min, max, /): # all positional-only args to avoid incompatibilities |
I would lean towards Side note: this is yet another example (like |
Only if they're positional, right? I actually do like your signature better - |
I only get lint errors for overriding builtins if I define variables with the same name as a builtin. Something like
|
cc @seberg (in case you have thoughts here) |
I agree that clip is clear enough that it seems fine to allow passing positional and |
Questions that were brought up yesterday:
|
if In NumPy both
|
I don't want to volunteer it, but it shouldn't be hard to change that in NumPy or fix in a compat namespace. And yes, it will mean that it isn't the same as a chained minimum/maximum call. |
At this point, I'd find it a bit inconsistent if We explicitly changed, e.g., the At the time of original API addition, I had advocated for returning an array having a dtype of the same type, but objections were raised (in PyTorch) about having certain APIs exempt from normal type promotion rules. |
The
clip
function is quite handy for constraining data to a certain range. Would be nice to include this in the specThe text was updated successfully, but these errors were encountered: