-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
ENH: Make the mode
parameter of np.pad default to 'constant'
#4808
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
Conversation
I (wrongly) expected |
That would be a sensible default--should I change it? |
Do we have any reason to believe that "constant" is a better default than
|
I don't think that applies here. If it did, the same argument could be used against almost any default value in any function. Do we have any reason to believe that the first axis is a better default than the last for ufunc's methods? That I would argue that default values are about convenience, and have nothing to do with guessing or ambiguity. And when I think of padding, I think of FFT, convolution, correlation... which all make extensive use of 0 padding. |
If one choice is more convenient, then that's not guessing. My concern is
|
The convenience comes from not having to type some code sometimes, even if there is no obvious choice, e,g, the axis and side examples before. |
Doesn't ndimage default to constant 0? |
To me constant 0 sounds obvious in the sense, that all the others seem somewhat specific to the context, which |
I added constant as the default. |
@njsmith Are you happy with this? |
I'm at about -0.3 :-) It's still not clear to me whether or not this is a good default (= obvious to everyone, consistent, etc.), esp. given that scipy.ndimage does in fact default to OTOH, whatever, it's probably not an actively bad default and this is not a critical issue, so I'm not going to stand in the way if you guys are happy and want to go ahead. |
It actually varies across |
mode
parameter positionalmode
parameter of np.pad positional
FWIW: I've used |
+1
|
Can you send a note to the list proposing this? That's our general policy
|
mode
parameter of np.pad positionalmode
parameter of np.pad default to 'constant'
More precedent - the |
Did this proposal ever make it to the mailing list? Was the discussion positive for setting the default |
+1 LGTM @stefanv can you rebase? |
For the record, this is not a backwards compat break (wasn't clear to me from the description). Hence the +1, just makes it easier, and yes this is the expected default behavior for most cases (signal/image processing) I'd say |
66ed12f
to
f45466d
Compare
CI failures, the override system seems to have made it harder to change signatures.
This needs a change to
right above the |
All green and a number of +1's, merging. Thanks @stefanv, all |
See the mailing list discussion initiated by Nadav Horesh