## Re: [Matplotlib-users] arange

 Re: [Matplotlib-users] arange From: Alan G Isaac - 2006-02-28 19:47:34 ```On Tue, 28 Feb 2006, Steve Schmerler apparently wrote:=20 > In [39]: a =3D arange(0, 0.005, 0.00001); len(a) Out[39]:=20 > 500=20 > In [40]: a =3D arange(0, 0.005, 0.000001); len(a)=20 > Out[40]: 5001=20 > Shouldn't len(a)%10 =3D=3D 0 in these cases?=20 Use numpy.linspace: linspace(start, stop, num=3D50, endpoint=3DTrue, retstep=3DFalse) Return evenly spaced numbers. Return 'num' evenly spaced samples from 'start' to 'stop'. If 'endpoint' is True, the last sample is 'stop'. If 'retstep' is True then return the step value used. Cheers, Alan Isaac PS http://docs.python.org/tut/node16.html ```

 [Matplotlib-users] arange From: Steve Schmerler - 2006-02-28 19:32:08 ```Hi I've a machine where I used Numeric until now. Does the following behaviour also occur with numpy? In [38]: Numeric.__version__ Out[38]: '23.8' In [39]: a = arange(0, 0.005, 0.00001); len(a) Out[39]: 500 In [40]: a = arange(0, 0.005, 0.000001); len(a) Out[40]: 5001 Shouldn't len(a)%10 == 0 in these cases? cheers, steve -- Random number generation is the art of producing pure gibberish as quickly as possible. ```
 Re: [Matplotlib-users] arange From: Robert Kern - 2006-02-28 19:42:59 ```Steve Schmerler wrote: > Hi > > I've a machine where I used Numeric until now. Does the following > behaviour also occur with numpy? > > > In [38]: Numeric.__version__ > Out[38]: '23.8' > > In [39]: a = arange(0, 0.005, 0.00001); len(a) > Out[39]: 500 > > In [40]: a = arange(0, 0.005, 0.000001); len(a) > Out[40]: 5001 > > Shouldn't len(a)%10 == 0 in these cases? Yes. Floating point is weird. http://projects.scipy.org/scipy/numpy/ticket/8 Use numpy.linspace() for reliable results. I think matplotlib exposes linspace(), too. -- Robert Kern robert.kern@... "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter ```
 Re: [Matplotlib-users] arange From: Alan G Isaac - 2006-02-28 19:47:34 ```On Tue, 28 Feb 2006, Steve Schmerler apparently wrote:=20 > In [39]: a =3D arange(0, 0.005, 0.00001); len(a) Out[39]:=20 > 500=20 > In [40]: a =3D arange(0, 0.005, 0.000001); len(a)=20 > Out[40]: 5001=20 > Shouldn't len(a)%10 =3D=3D 0 in these cases?=20 Use numpy.linspace: linspace(start, stop, num=3D50, endpoint=3DTrue, retstep=3DFalse) Return evenly spaced numbers. Return 'num' evenly spaced samples from 'start' to 'stop'. If 'endpoint' is True, the last sample is 'stop'. If 'retstep' is True then return the step value used. Cheers, Alan Isaac PS http://docs.python.org/tut/node16.html ```