On Thu, Feb 18, 2016 at 2:19 PM, Alan Isaac <alan.is...@gmail.com> wrote:
> Would such a new function correct the apparent mistake (?) of > `linspace` including the endpoint by default? > Or is the current API justified by its Matlab origins? > I don't think so -- we don't need no stinkin' Matlab ! But I LIKE including the endpoint in the sequence -- for the common use cases, it's often what you want, and if it didn't include the end point but you did want that, it would get pretty ugly to figure out how to get what you want. On the other hand, if I had it to do over, I would have the count specify the number of intervals, rather than the number of items. A common cae may be: values from zero to 10 (inclusive), and I want ten steps: In [19]: np.linspace(0, 10, 10) Out[19]: array([ 0. , 1.11111111, 2.22222222, 3.33333333, 4.44444444, 5.55555556, 6.66666667, 7.77777778, 8.88888889, 10. ]) HUH? I was expecting [0,1,2,3 ....] (OK, not me, this isn't my first Rodeo), so now I need to do: In [20]: np.linspace(0, 10, 11) Out[20]: array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.]) This gets uglier if I know what "delta" I want: In [21]: start = 0.0; end = 9.0; delta = 1.0 In [24]: np.linspace(start, end, (end-start)/delta) Out[24]: array([ 0. , 1.125, 2.25 , 3.375, 4.5 , 5.625, 6.75 , 7.875, 9. ]) oops! In [25]: np.linspace(start, end, (end-start)/delta + 1) Out[25]: array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.]) But in any case, there is no changing it now. -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion