[Numpy-discussion] missing array type
oliphant.travis at ieee.org
Tue Feb 28 12:19:02 CST 2006
>>>>b = array()
>>>>ndarray((5,), strides=(0,), buffer=b)
>Traceback (most recent call last):
> File "<stdin>", line 1, in ?
>TypeError: buffer is too small for requested array
>I would think memory-saving is the only justification for allowing
>What use does your change enable?
I was just simplifying the PyArray_CheckStrides code.
I didn't try to actually enable creating 0-stride arrays in
I don't mind if it is enabled though. I just haven't done it yet.
I agree that 0-stride arrays are a "can-of-worms", and I also do not see
changing ufunc behavior. The current behavior is understandable and
exactly what one would expect with zero-stride and multiple dimensioned
b = arange(5);
b.strides = 0
where b has shape (5,) and stride (0,) would add 1 to the first element
of b 5 times. Since all elements of the array b are obtained from the
first element (that's what stride=0 means), you end up with an array of
all 5's. This may not be useful, I agree, but it is understandable and
changing it would be too much of an exception. If somebody is creating
0-stride arrays on their own, then they must know what they are doing.
More information about the Numpy-discussion