[Numpy-discussion] Indexing a matrix with a scalar and ticket #707
Charles R Harris
Mon Apr 28 20:41:22 CDT 2008
On Mon, Apr 28, 2008 at 7:03 PM, Charles R Harris <firstname.lastname@example.org>
> Yes, indeed.
> Ticket #707: numpy.array fails if the input is a list of matrixes (with
> more then one column).
> The subroutine discover_dimensions in arrayobject.c indexes a matrix with
> a scalar. It is a recursive routine and expects to find the next lower
> dimension as it recurses down into the matrix. This works fine with matrices
> with one column because the matrix row also has first dimension 1. Things
> don't do so well if the matrices have more than one column. I expect this is
> just the tip of a big pile of, um, stuff. The easy fix is to make indexing
> by scalars the same for matrices and arrays. So I think the best thing to do
> is provide that and figure out how to get the subarrays some other way.
Let me add that this settles the case of the matrix iterator for me: it has
to return a 1D array. That behavior is part of the numpy contract that the
core code is built on. The behavior of scalar indexing may also be part of
that contract, but I am not sure of that.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion