[Numpy-discussion] Re: change in semantics of arange?
Todd Miller
jmiller at stsci.edu
Fri May 16 11:37:09 EDT 2003
On Fri, 2003-05-16 at 13:03, Paul Dubois wrote:
> C:\numpy\numarray\Packages\MA2>python
> Python 2.3b1 (#40, Apr 25 2003, 19:06:24) [MSC v.1200 32 bit (Intel)] on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import numarray
> >>> x=numarray.arange(5,3,2)
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "c:\python23\Lib\site-packages\numarray\numarray.py", line 924, in
> arange
> r = _fillarray(size, start, stride, type)
> File "c:\python23\Lib\site-packages\numarray\numarray.py", line 120, in
> _fillarray
> outarr = NumArray((size,), outtype)
> libnumarray.error: NA_updateDataPtr: error getting read buffer data ptr
> >>> import Numeric
> >>> Numeric.arange(5,3,2)
> zeros((0,), 'l')
> >>>
>
> Is this change intentional?
No. It's bugs in arange and also the memory object which are creating a
negative length buffer. The buffer API then reports a negative length
which is fortuitously interpreted as an error. Ya gotta smile...
It's fixed in CVS. I modified the memory module so that:
>>> import memory
>>> memory.new_memory(-10)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: new_memory: invalid region size: -10.
And I modified arange so that negative sizes are clipped to 0. So now:
>>> import numarray
>>> numarray.arange(5,3,2)
array([])
>
--
Todd Miller jmiller at stsci.edu
STSCI / ESS / SSB
More information about the NumPy-Discussion
mailing list