[Numpy-discussion] arange(start, stop, step) and floating point (Ticket #8)

Travis Oliphant oliphant at ee.byu.edu
Wed Feb 8 15:00:33 CST 2006


Sasha wrote:

>On 2/8/06, Robert Kern <robert.kern at gmail.com> wrote:
>  
>
>> ...
>>arange() does allow for fractional steps unlinke range(). You may fix the
>>docstring if you like. However, I don't think it is possible to ensure that
>>invariant in the face of floating point. That's why we have linspace().
>>    
>>
>
>There is certainly a way to ensure that arange(..., stop, ...)[-1] <
>stop in the face of floating point -- just repeat start += step with
>start in a volatile double variable until it exceeds stop to get the
>length of the result.   There might be an O(1) solution as well, but
>it may require some assumptions about the floating point unit.
>
>In any case, I can do one of the following depending on a vote:
>
>1 (default). Document length=ceil((stop - start)/step) in the arange docstring
>  
>
+5

We can't really do anything else at this point since this behavior has 
been what is with us for a long time.

-Travis






More information about the Numpy-discussion mailing list