[Numpy-discussion] Matching 0-d arrays and NumPy scalars

Alan G Isaac aisaac@american....
Thu Feb 21 11:08:32 CST 2008

On Thu, 21 Feb 2008, Konrad Hinsen apparently wrote:

> What I see as more fundamental is the behaviour of Python container 
> objects (lists, sets, etc.). If you add an object to a container and 
> then access it as an element of the container, you get the original 
> object (or something that behaves like the original object) without 
> any trace of the container itself. 

I am not a CS type, but your statement seems related to
a matrix behavior that I find bothersome and unnatural::

    >>> M = N.mat('1 2;3 4')
    >>> M[0]
    matrix([[1, 2]])
    >>> M[0][0]
    matrix([[1, 2]])

I do not think anyone has really defended this behavior,
*but* the reply to me when I suggested that a matrix 
contains arrays and we should see that in its behavior
was that, no, a matrix is a container of matrices so this is 
what you get.

So a possible problem with your phrasing of the argument
(from a non-CS, user point of view)
is that it fails to address what is actually "contained"
(as opposed to what you might wish were contained).

Apologies if this proves OT.

Alan Isaac

More information about the Numpy-discussion mailing list