[Numpy-discussion] arange including stop value?

Anne Archibald peridot.faceted@gmail....
Thu Mar 11 18:46:09 CST 2010


On 11 March 2010 19:30, Tom K. <tpk@kraussfamily.org> wrote:
>
>
>
> davefallest wrote:
>>
>> ...
>> In [3]: np.arange(1.01, 1.1, 0.01)
>> Out[3]: array([ 1.01,  1.02,  1.03,  1.04,  1.05,  1.06,  1.07,  1.08,
>> 1.09,  1.1 ])
>>
>> Why does the ... np.arange command end up including my stop value?

Don't use arange for floating-point values. Use linspace instead.

Anne

> >From the help for arange:
>
>        For floating point arguments, the length of the result is
>        ``ceil((stop - start)/step)``.  Because of floating point overflow,
>        this rule may result in the last element of `out` being greater
>        than `stop`.
>
> --
> View this message in context: http://old.nabble.com/arange-including-stop-value--tp27866607p27872069.html
> Sent from the Numpy-discussion mailing list archive at Nabble.com.
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list