[Numpy-discussion] Adding zero-dimension arrays, bug?

David Paul Reichert D.P.Reichert@sms.ed.ac...
Tue Jun 9 09:38:11 CDT 2009


Numpy let's me define arrays with zero rows and/or
columns, and that's wanted behaviour from what I have
read in discussions. However, I can add an array
with zero rows to an array with one row (but not more),
resulting in another zero row array, like so:

In: a = zeros((4,0))

In: a
Out: array([], shape=(4, 0), dtype=float64)

In: b = zeros((4,1))

In: b
array([[ 0.],
        [ 0.],
        [ 0.],
        [ 0.]])

In: a + b
Out: array([], shape=(4, 0), dtype=float64)

Is this a bug? This should give a shape mismatch error,



The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

More information about the Numpy-discussion mailing list