[Numpy-discussion] numpy.arange() error?

Benjamin Root ben.root at ou.edu
Thu Feb 9 18:40:31 EST 2012


On Thursday, February 9, 2012, Sturla Molden <sturla at molden.no> wrote:
>
>
> Den 9. feb. 2012 kl. 22:44 skrev eat <e.antero.tammi at gmail.com>:
>
>>
> Maybe this issue is raised also earlier, but wouldn't it be more
consistent to let arange operate only with integers (like Python's range)
and let linspace handle the floats as well?
>
>
> Perhaps. Another possibility would be to let arange take decimal
arguments, possibly entered as text strings.
> Sturla


Personally, I treat arange() to mean, "give me a sequence of values from x
to y, exclusive, with a specific step size".  Nowhere in that statement
does it guarantee a particular number of elements.  Whereas linspace()
means, "give me a sequence of evenly spaced numbers from x to y, optionally
inclusive, such that there are exactly N elements". They complement each
other well.

There are times when I intentionally will specify a range where the step
size will not nicely fit.  i.e.- np.arange(1, 7, 3.5). I wouldn't want this
to change.

My vote is that if users want matlab-colon-like behavior, we could make a
new function - maybe erange() for "exact range"?

Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120209/2652a81c/attachment.html>


More information about the NumPy-Discussion mailing list