[SciPy-User] scipy.optimize named argument inconsistency

Bruce Southey bsouthey@gmail....
Tue Sep 6 13:53:44 CDT 2011

On 09/06/2011 01:30 PM, Denis Laxalde wrote:
> On Tue, 6 Sep 2011 19:08:22 +0200,
> Ralf Gommers wrote:
>>> One possibility, that has been used in numpy.histogram, is to add a
>>> "new=False" or "new=True" keyword, to switch behavior during
>>> transition.
>> This may apply to a few cases where the outputs should be reshuffled or
>> changed, but we should try to minimize "new=" - it requires the user to
>> change his code twice because eventually the new keyword should also
>> disappear again. The histogram change didn't go very smoothly imho. If the
>> changes are large, another option is to just deprecate the whole function
>> and write a new one with the desired interface. That would just require a
>> single change for the user. It does depend on whether a good new name can be
>> found of course.
>> For renaming of input parameters (both positional and keyword), just do the
>> rename and then add the old name as a new keyword at the end. Then document
>> in the docstring that it's deprecated, and check for it at the beginning of
>> the function and if used do:
>> warnings.warn("<informative message>", DeprecationWarning)
>> The message should also state the scipy version when it was deprecated (0.11
>> probably) and when it will disappear (0.12).
> Ok. Sounds good.
>> Could you make an overview of which functions should be changed, and your
>> proposed new unified interface? The best solution could depend on the
>> details of the changed needed.
> The first thing to do is to improve names consistency, imo. I will
> review all functions of the package and then post a list of possible
> improvements. Then, I need to think a bit more about the new « unified
> interfaces » idea as it could indeed solve some issues. As
> suggested, I'll create a page on<http://projects.scipy.org/scipy>  when
> things will be more clear.
I would say Ralf's idea of new functions would be the best approach even 
if scipy is still beta. But I would extend it by providing that 
suggested unified function and creating  'internal' versions (have a 
leading underscore) of existing functions. While it is initially code 
duplication, it also permits to change not only the argument but also 
the return values as needed. Thus you would have the advantage provided 
by Ralf and avoid the naming problem without affecting existing users.


More information about the SciPy-User mailing list