[Numpy-discussion] Getting 0.9.8 out this week
Stephan Tolksdorf
st at sigmasquared.net
Wed May 10 02:31:22 EDT 2006
I'm +1 for returning scalars instead of 1x1 for reduce-like methods on
matrices in case no axis is specified.
Tim Hochberg wrote:
> >>> m.max(1).max(0)
> matrix([[8]])
> >>> a.max(1).max(0)
> 8
(...)
> If we switch to having m.max() return a scalar, then this equivalence
> goes away. That makes things harder to explain.
>
> So, in the absence of more compelling use cases that those presented in
> the ticket I'd be inclined to leave things as they are. Of course I'm
> not a user of the matrix class, so take that for what it's worth.
I don't think symmetry between matrix and array classes should be an
argument for doing things a certain way for matrices when there are
other arguments against it, because matrices were meant to behave
differently in the first place.
As to the consistency of explanation, why isn't it consistent to say
that max() returns a scalar and max(axis) returns a column or row vector
(in form of a matrix)?
I don't see a problem with m.max(1).max(0) still returning a 1x1 matrix,
though I think for matrix multiplication broadcasting rules shouldn't be
applied to 1x1 matrices. (Is there any use for broadcasting rules
applied to matrix multiplication in general?)
Regards,
Stephan
More information about the NumPy-Discussion
mailing list