1 Jun 2011 02:31
Re: what does "in" do with numpy arrays?
Robert Kern <robert.kern <at> gmail.com>
2011-06-01 00:31:21 GMT
2011-06-01 00:31:21 GMT
On Tue, May 31, 2011 at 11:25, Christopher Barker <Chris.Barker <at> noaa.gov> wrote: > Hi folks, > > I've re-titled this thread, as it's about a new question, now: > > What does: > > something in a_numpy_array > > mean? i.e. how has __contains__ been defined? > > A couple of us have played with it, and can't make sense of it: > >> In [24]: a >> Out[24]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) >> >> In [25]: 3 in a >> Out[25]: True >> >> So the simple case works just like a list. But what If I look for an array in another array? > >> In [26]: b >> Out[26]: array([3, 6, 4]) >> >> In [27]: b in a >> Out[27]: False >> >> OK, so the full b array is not in a, and it doesn't "vectorize" it, >> either. But: >>(Continue reading)
RSS Feed