I was porting some code over from matlab in which I relied on the upper bound of linspace to be met exactly.

It turns out that it isn't always exactly met in numpy.

In [390]: filter(lambda x: x[1]!=0.0, [ (i, 1.0-numpy.linspace(0,1,i)[-1]) for i in range(2,200) ])
Out[390]:
[(50, 1.1102230246251565e-016),
 (99, 1.1102230246251565e-016),
 (104, 1.1102230246251565e-016),
 (108, 1.1102230246251565e-016),
 (162, 1.1102230246251565e-016),
 (188, 1.1102230246251565e-016),
 (197, 1.1102230246251565e-016),
 (198, 1.1102230246251565e-016)]


I know it's not a good idea to count on floating point equality in general, but still it doesn't seem too much to expect that the first and last values returned by linspace are exactly the values asked for if they both have exact floating point representations.

--bb
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to