2011/9/20 Stéfan van der Walt <ste...@sun.ac.za> > On Tue, Sep 20, 2011 at 12:43 AM, Robert Kern <robert.k...@gmail.com> > wrote: > > If the array is short in a dimension, it gets implicitly continued > > with Falses. You can see this in one dimension: > > [...] > > > I honestly don't know if this is documented or tested anywhere or even > > if this existed in older versions. > > The behaviour is already present in 1.4, so I guess it's too late to > insert a shape check now? > > There already is a shape check present in the development version[1]:
>>> a = np.arange(10) >>> b = np.array([False, True, False]) >>> a[b] Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: operands could not be broadcast together with shapes (10) (3) But it does not seem to work on multidimensional arrays: >>> c = np.arange(12).reshape((4,3)) >>> c[b] array([[3, 4, 5]]) I also noticed that it does strange things when using a list: >>> c[[True, False, True]] array([[3, 4, 5], [0, 1, 2], [3, 4, 5]]) Regards, Han [1] See also: http://mail.scipy.org/pipermail/numpy-discussion/2011-July/057870.html
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion