-
-
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: Simplify return value of ndimage functions. #8461
Conversation
I am not making an objection but rather a offering a comment to document the apparent but so far unmentioned motivation for the original behavior: the idea that a function that mutates its argument should return None. It is therefore hard to consider such behavior unexpected or unintuitive; it might even be considered to be preferred. (E.g., https://mail.python.org/pipermail/python-dev/2003-October/038855.html ) |
b88a991
to
b046012
Compare
I understand and respect the distinction between What I find harmful is having a single function that behaves wildly different depending on what its inputs are, because it basically forces you to have something like:
instead of the much more simple, readable and understandable:
|
Aside from the change in return value behaviour, this also fixes a bug in the return value of |
Needs a rebase. On merge also needs an entry in https://github.com/scipy/scipy/wiki/Release-note-entries-for-SciPy-1.1.0 |
+1 for this change |
THe original code was broken: if we called binary_erosion with iterations=0 and brute_force=True, and the first iteration returned the input unchanged, the output array wasn't being modified at all, and was being returned as initialized.
55dd944
to
775ca60
Compare
Have rebased. Once this is merged, will add the following text to the release notes in the Backwards incompatible changes section. Functions in the |
Okay in it goes. Thanks @jaimefrio! |
Thanks for the review! |
Simplifies the return value of ndimage functions, so that the
output
array is always returned, instead of the awkward current behavior, where many (but not all) functions only return theoutput
array if it has been allocated by the function, and returnNone
if it has been passed by the user through theoutput=
keyword argument.