[SciPy-Dev] docstring standard: parameter shape description

Jonathan Guyer guyer@nist....
Wed Jan 30 08:21:52 CST 2013

On Jan 29, 2013, at 6:06 PM, Joe Harrington wrote:

>> As we reported in http://projects.scipy.org/numpy/ticket/1171, the
>> treatment of 0-length dimensions is buggy, but NumPy nonetheless
>> allows for it.
> I did the following test before I posted:
>>>> import numpy as np
>>>> a=np.array(((2,3),(3,4)))
>>>> a
> array([[2, 3],
>       [3, 4]])
>>>> a.shape
> (2, 2)
>>>> a.shape=(2,0,2)
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> ValueError: total size of new array must be unchanged
> So, you can't have a 0-element dimension in an array that is not already
> 0-size.  

I guess that's to be expected. That use case doesn't arise for us, so I can't say whether it would be expected or desirable to be able to do such a reshaping.

> I didn't think about 0-size arrays having some non-zero
> dimensions.  I guess that makes mathematical sense, but then what is the
> point?

Like I said, one point is to be able to deal with an array partitioned across multiple processors in a consistent way. If the number of processors doesn't evenly divide into the array size, then it's possible to end up with "empty" arrays that are semantically consistent with all of the other "full" arrays.

> Between this and your bug report, I wonder whether a 0-element array
> dimension is a feature you can rely on.  Can a developer let us know if
> it's an accident that it works at all?  

Well, I don't know if it was originally an accident, but Travis agreed with my original bug report.

> I'll leave it to you to start a
> new thread on this and get the inconsistencies resolved, since you're
> the one using the feature.  The report was last touched 3 years ago...

I discovered after I posted that this ticket is very much alive and well at


with an active pull request to fix it at 


More information about the SciPy-Dev mailing list