[Numpy-discussion] Getting 0.9.8 out this week
Alan G Isaac
aisaac at american.edu
Tue May 9 23:19:03 EDT 2006
>> On Tue, 09 May 2006, Tim Hochberg apparently wrote:
>>> Let's start with the example in the ticket:
>>> >>> m.argmax()
>>> matrix([[8]])
>>> Does anyone else think that this is a fairly nonsensical result?
> Alan G Isaac wrote:
>> Yes. The result should be a scalar.
On Tue, 09 May 2006, Tim Hochberg apparently wrote:
> Why? The current behaviour is both more self consistent and easier to
> explain, so it would be nice to see some examples of how a scalar would
> be advantageous here.
Because that is the result for array.
For consistency, I think
m.argmax()
m.A.argmax()
should be equivalent.
(Also along axes, and therefore never returning matrices.
And let ravel really ravel it, rather than duplicating hstack!
What is the principal at work: must matrices always produce
matrices almost no matter what we do with them?
I prefer the principle that standard matrix operations
on matrices return matrices. But then, I see I am not ready to
be consistent, as I do want m.max(num) to be a matrix ... )
> Now if a.argmax() returned (2, 2) in this case, that would
> be useful
Agreed.
I should not have implied that a scalar return is "better"
than a tuple in this case. But this seems a radical change
in behavior. If this is the behavior desired in this case,
does that not suggest a behavior change for every case? That
is, are you not in effect arguing that argmax should some
kind of indexing object such that
a.max(num) == a[a.argmax(num)]
This seems quite useful but entirely new.
Cheers,
Alan Isaac
More information about the NumPy-Discussion
mailing list