[SciPy-user] "in" vs. looped "=="
R. Padraic Springuel
R.Springuel at umit.maine.edu
Wed Mar 12 16:23:08 EDT 2008
I have some code that uses a "1. in x" statement early on, where x is a
rank-1 ndarray with dtype=float. This statement returns False and the
program continues accordingly. However, later on in the same code I
loop over the elements of x and the statement "x[i] == 1" is evaluated
and comes back as True for some elements of x. To my mind, that
shouldn't be happening. Is there a difference in how "1. in x" (i.e.
the __contains__ method of ndarray) and "x[i] == 1." (i.e. the __eq__
property of float) behave that I'm not aware of?
--
R. Padraic Springuel
Research Assistant
Department of Physics and Astronomy
University of Maine
Bennett 309
Office Hours: By appointment only
More information about the SciPy-User
mailing list