[Numpy-discussion] Should ndarray subclasses support the keepdims arg?

2015-05-05 Thread Allan Haldane
Hello all, A question: Many ndarray methods (eg sum, mean, any, min) have a keepdims keyword argument, but ndarray subclass methods sometimes don't. The 'matrix' subclass doesn't, and numpy functions like 'np.sum' intentionally drop/ignore the keepdims argument when called with an ndarray

Re: [Numpy-discussion] Should ndarray subclasses support the keepdims arg?

2015-05-05 Thread Allan Haldane
That makes sense. I think it's the way to go, thanks. The downside is using **kwargs instead of an explicit keepdims arg gives a more obscure signature, but using the new __signature__ attribute this could be hidden for python 3 users and python2 using ipython3+. On 05/05/2015 01:55 PM,

Re: [Numpy-discussion] Should ndarray subclasses support the keepdims arg?

2015-05-05 Thread Nathaniel Smith
AFAICT the only real solution here is for np.sum and friends to propagate the keepdims argument if and only if it was explicitly passed to them (or maybe the slightly different, if and only if it has a non-default value). If we just started requiring code to handle it and passing it

Re: [Numpy-discussion] Should ndarray subclasses support the keepdims arg?

2015-05-05 Thread Nathaniel Smith
On May 5, 2015 11:05 AM, Neil Girdhar mistersh...@gmail.com wrote: Maybe they should have written their code with **kwargs that consumes all keyword arguments rather than assuming that no keyword arguments would be added? The problem with this approach in general is that it makes writing code

Re: [Numpy-discussion] Should ndarray subclasses support the keepdims arg?

2015-05-05 Thread Neil Girdhar
Maybe they should have written their code with **kwargs that consumes all keyword arguments rather than assuming that no keyword arguments would be added? The problem with this approach in general is that it makes writing code unnecessarily convoluted. On Tue, May 5, 2015 at 1:55 PM, Nathaniel

Re: [Numpy-discussion] Should ndarray subclasses support the keepdims arg?

2015-05-05 Thread Sebastian Berg
On Di, 2015-05-05 at 11:13 -0400, Allan Haldane wrote: Hello all, A question: Many ndarray methods (eg sum, mean, any, min) have a keepdims keyword argument, but ndarray subclass methods sometimes don't. The 'matrix' subclass doesn't, and numpy functions like 'np.sum' intentionally