[Numpy-discussion] simple problem with arange / roundoff
Keith Goodman
kwgoodman at gmail.com
Tue Jul 31 10:41:25 EDT 2007
On 7/31/07, Eric Emsellem <emsellem at obs.univ-lyon1.fr> wrote:
> Here is an example:
>
> start = -30.
> end = 30.
> npix = 31
> step = (end - start) / (npix - 1.)
> gridX = num.arange(start-step/2., end+step/2., step)
> array([-31., -29., -27., -25., -23., -21., -19., -17., -15., -13., -11.,
> -9., -7., -5., -3., -1., 1., 3., 5., 7., 9., 11.,
> 13., 15., 17., 19., 21., 23., 25., 27., 29.])
>
> As you can see, it does not go up to 31., but only to 29, although step
> is = 2.0
>> import numpy.matlib as M
>> M.linspace(-30,30,31)
array([-30., -28., -26., -24., -22., -20., -18., -16., -14., -12., -10.,
-8., -6., -4., -2., 0., 2., 4., 6., 8., 10., 12.,
14., 16., 18., 20., 22., 24., 26., 28., 30.])
More information about the NumPy-Discussion
mailing list