[Numpy-discussion] arange(-10)

Pearu Peterson pearu at cens.ioc.ee
Mon Oct 7 05:26:05 EDT 2002

On Mon, 7 Oct 2002, Todd Miller wrote:

> The subject line contains what I consider to be an invalid range 
> expression.   Numarray, now and always, reacts badly to it.  Currently, 
> numarray tries to allocate a multi-gigabyte array.   In the past, it has 
> dumped core.
> The question is, what should it do?
> 1. raise ValueError, "Invalid negative range expression"     (my +1)
> 2. zeros((0,), 'l')                                                     
>                   (Numeric does this)
> Is there a good justification to keep the existing Numeric behavior? 
>  Any other suggestions?

Does Numarray support empty arrays? If yes, I'd vote for Python behavior:

>>> range(-10)

Otherwise, the case 1.

Hmm, according to Numeric.arange docs, "arange is just like
range() except it returns an array whose type can be specified ...".
But given example shows that there are other (undocumented?) exceptions
when comparing arange and range.


More information about the NumPy-Discussion mailing list