Use of `input` in ndimage

I submitted a PR ( https://github.com/scipy/scipy/pull/3745#issuecomment-46590839) to remove use of the built-in Python function name `input` from the ndimage module, where it is used as the argument name for the input data in almost every single function. A full list of functions involved has been pulled by Warren on the discussion of that PR. Warren wisely pointed out that changing the name of an argument changes the API, and should therefore not be done lightly, as it could break existing user code. One could argue. or at least wish, that, since `input` is typically the first argument of the functions involved, and is non-optional, calls using it as a keyword argument should be rare. But the potential harm is undeniable. It is ugly and a clear violation of PEP8, but although this kind of things are usually an accident waiting to happen, it has also proven harmless so far. So for now I have simply closed the PR, letting practicality beat purity. And so it will remain, unless the community thinks this special case is not special enough to break the rules. Inputs on how to handle the API change to minimize impact to users are also welcome. Thanks, Jaime -- (\__/) ( O.o) ( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.

On Thu, Jun 19, 2014 at 7:46 PM, Jaime Fernández del Río <jaime.frio@gmail.com> wrote:
I submitted a PR (https://github.com/scipy/scipy/pull/3745#issuecomment-46590839) to remove use of the built-in Python function name `input` from the ndimage module, where it is used as the argument name for the input data in almost every single function. A full list of functions involved has been pulled by Warren on the discussion of that PR.
Warren wisely pointed out that changing the name of an argument changes the API, and should therefore not be done lightly, as it could break existing user code. One could argue. or at least wish, that, since `input` is typically the first argument of the functions involved, and is non-optional, calls using it as a keyword argument should be rare. But the potential harm is undeniable.
It is ugly and a clear violation of PEP8, but although this kind of things are usually an accident waiting to happen, it has also proven harmless so far. So for now I have simply closed the PR, letting practicality beat purity. And so it will remain, unless the community thinks this special case is not special enough to break the rules. Inputs on how to handle the API change to minimize impact to users are also welcome.
I don't find the current situation particularly problematic. `input()` is not a function that is used anywhere in ndimage (indeed, using it would be a much worse problem than shadowing a builtin), and ndimage is not so frequently modified that anything like this is actually likely to cause a problem in the future. I do see that `>>> input = ...` is used in some of the docstring examples; cleaning those up *would* be worth doing. -- Robert Kern
participants (2)
-
Jaime Fernández del Río
-
Robert Kern