List of function-like things with an 'out' parameter

On Wed, May 28, 2008 at 3:34 PM, Charles R Harris >> I wonder if this is something that ought to be looked at for all
functions with an "out" parameter? ndarray.compress also had problems with array type mismatch (#789); I can't imagine that it's safe to assume only these two functions were doing it incorrectly. (Unless of course somebody has recently looked at all of them)
I think that is an excellent idea! A good start would be to list all the functions with the out parameter and then write some tests. The current behavior is inconsistent and we not only need to specify the behavior, but fix all the places that don't follow the rules.
Here's a list of things in numpy that have an 'out' argument (and their arguments); I think I eliminated all the duplicated items (that are imported from a subpackage into one of the main packages, for example). There's stuff that's missing, probably; I think the C-implemented functions don't have argument lists programmatically available so I may parse their docstrings or something, but this is a start. numpy.all ['a', 'axis', 'out'] numpy.alltrue ['a', 'axis', 'out'] numpy.amax ['a', 'axis', 'out'] numpy.amin ['a', 'axis', 'out'] numpy.any ['a', 'axis', 'out'] numpy.around ['a', 'decimals', 'out'] numpy.choose ['a', 'choices', 'out', 'mode'] numpy.clip ['a', 'a_min', 'a_max', 'out'] numpy.compress ['condition', 'a', 'axis', 'out'] numpy.core.cumprod ['a', 'axis', 'dtype', 'out'] numpy.core.cumproduct ['a', 'axis', 'dtype', 'out'] numpy.core.cumsum ['a', 'axis', 'dtype', 'out'] numpy.core.defmatrix.matrix.all ['self', 'axis', 'out'] numpy.core.defmatrix.matrix.any ['self', 'axis', 'out'] numpy.core.fromnumeric.mean ['a', 'axis', 'dtype', 'out'] numpy.core.fromnumeric.prod ['a', 'axis', 'dtype', 'out'] numpy.core.fromnumeric.product ['a', 'axis', 'dtype', 'out'] numpy.core.fromnumeric.ptp ['a', 'axis', 'out'] numpy.core.fromnumeric.round_ ['a', 'decimals', 'out'] numpy.core.fromnumeric.sometrue ['a', 'axis', 'out'] numpy.core.fromnumeric.std ['a', 'axis', 'dtype', 'out', 'ddof'] numpy.core.fromnumeric.sum ['a', 'axis', 'dtype', 'out'] numpy.core.fromnumeric.take ['a', 'indices', 'axis', 'out', 'mode'] numpy.core.fromnumeric.trace ['a', 'offset', 'axis1', 'axis2', 'dtype', 'out'] numpy.core.fromnumeric.var ['a', 'axis', 'dtype', 'out', 'ddof'] numpy.lib.function_base.median ['a', 'axis', 'out', 'overwrite_input'] numpy.ma.choose ['indices', 't', 'out', 'mode'] numpy.ma.core.MaskedArray.compress ['self', 'condition', 'axis', 'out'] numpy.ma.core.max ['obj', 'axis', 'out'] numpy.ma.core.min ['array', 'axis', 'out'] numpy.ma.core.round_ ['a', 'decimals', 'out'] numpy.ma.extras.median ['a', 'axis', 'out', 'overwrite_input']

2008/5/28 Alan McIntyre <alan.mcintyre@gmail.com>:
On Wed, May 28, 2008 at 3:34 PM, Charles R Harris >> I wonder if this is something that ought to be looked at for all
functions with an "out" parameter? ndarray.compress also had problems with array type mismatch (#789); I can't imagine that it's safe to assume only these two functions were doing it incorrectly. (Unless of course somebody has recently looked at all of them)
I think that is an excellent idea! A good start would be to list all the functions with the out parameter and then write some tests. The current behavior is inconsistent and we not only need to specify the behavior, but fix all the places that don't follow the rules.
Here's a list of things in numpy that have an 'out' argument (and their arguments); I think I eliminated all the duplicated items (that are imported from a subpackage into one of the main packages, for example). There's stuff that's missing, probably; I think the C-implemented functions don't have argument lists programmatically available so I may parse their docstrings or something, but this is a start.
Nice! One noticeable absence is all the ufuncs. (Partly this is because it's not actually called "out", or on fact anything at all; it's just the last parameter if there are enough.) You might also check things like objects returned by vectorize() and frompyfunc(). Does it make sense to put this list on the Wiki somewhere, so that people who come across new things that take output parameters (however named) can post them? Anne

On Wed, May 28, 2008 at 7:26 PM, Anne Archibald <peridot.faceted@gmail.com> wrote:
One noticeable absence is all the ufuncs. (Partly this is because it's not actually called "out", or on fact anything at all; it's just the last parameter if there are enough.) You might also check things like objects returned by vectorize() and frompyfunc().
Here's an updated version of the list that includes ufuncs.
Does it make sense to put this list on the Wiki somewhere, so that people who come across new things that take output parameters (however named) can post them?
I generated the list with a script; I don't know if that should be kept somewhere too. It could be modified to look for other things as well; I'm not sure how often people need lists of every function object in numpy with a given argument, though. Alan

On Wed, May 28, 2008 at 5:46 PM, Alan McIntyre <alan.mcintyre@gmail.com> wrote:
On Wed, May 28, 2008 at 7:26 PM, Anne Archibald <peridot.faceted@gmail.com> wrote:
One noticeable absence is all the ufuncs. (Partly this is because it's not actually called "out", or on fact anything at all; it's just the last parameter if there are enough.) You might also check things like objects returned by vectorize() and frompyfunc().
Here's an updated version of the list that includes ufuncs.
Does it make sense to put this list on the Wiki somewhere, so that people who come across new things that take output parameters (however named) can post them?
I generated the list with a script; I don't know if that should be kept somewhere too. It could be modified to look for other things as well; I'm not sure how often people need lists of every function object in numpy with a given argument, though.
This might add some also: PyUFunc_GenericReduction Chuck
participants (3)
-
Alan McIntyre
-
Anne Archibald
-
Charles R Harris