[SciPy-user] Numpy floating point comparisons

Matthieu Brucher matthieu.brucher@gmail....
Fri Dec 12 00:41:55 CST 2008


I don't think you can do better than make a new difference array, get
its absolute value, compare it to some small value and use the result.
This it what you would do in any language, so try it ;)


2008/12/12 Zane Selvans <zane@ideotrope.org>:
> Okay, let's try that again...
> I'm sure that this problem has come up before, and caused headaches, and
> hopefully someone can just point me at the appropriate documentation... but,
> I'm having issues doing floating point value comparisons...
> Specifically, I have two arrays of floating point values A and B, which have
> different lengths, and I want to do something semantically equivalent to:
> X = B[where(A in B[:,0])] ]
> But the array set operations of course don't do well when the values being
> compared are floating point, so:
> X = B[where(numpy.lib.arraysetops.setmember1d(B[:,0],A))]
> works unreliably.
> Is there a way to do this quickly, that also works for floating point
> values?
> --
> Zane Selvans
> Amateur Earthling
> zane@ideotrope.org
> 303/815-6866
> http://zaneselvans.org
> PGP Key: 55E0815F
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user

Information System Engineer, Ph.D.
Website: http://matthieu-brucher.developpez.com/
Blogs: http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn: http://www.linkedin.com/in/matthieubrucher

More information about the SciPy-user mailing list