Re: [Numpy-discussion] Can't mix np.newaxis with boolean indexing

2011-08-21 Thread Benjamin Root
On Sunday, August 21, 2011, Torgil Svensson wrote: > Since the result is one-dimensional after using boolean indexing you > can always do: > > a[b][:, np.newaxis] > array([[2], > [3], > [4]]) > > a[b][np.newaxis, :] > array([[2, 3, 4]]) > > //Torgil Correct, which I already noted

Re: [Numpy-discussion] Can't mix np.newaxis with boolean indexing

2011-08-21 Thread Torgil Svensson
Since the result is one-dimensional after using boolean indexing you can always do: a[b][:, np.newaxis] array([[2], [3], [4]]) a[b][np.newaxis, :] array([[2, 3, 4]]) //Torgil On Sat, Aug 20, 2011 at 10:17 PM, Benjamin Root wrote: > On Sat, Aug 20, 2011 at 2:47 AM, Olivier Ver

Re: [Numpy-discussion] Can't mix np.newaxis with boolean indexing

2011-08-20 Thread Benjamin Root
On Sat, Aug 20, 2011 at 2:47 AM, Olivier Verdier wrote: > Your syntax is not as intuitive as you may think. > > Suppose I take a matrix instead > > a = np.array([1,2,3,4]).reshape(2,2) > b = (a>1) # np.array([[False,True],[True,True]]) > > How would a[b,np.newaxis] be supposed to work? > > Note t

Re: [Numpy-discussion] Can't mix np.newaxis with boolean indexing

2011-08-20 Thread Olivier Verdier
Your syntax is not as intuitive as you may think. Suppose I take a matrix instead a = np.array([1,2,3,4]).reshape(2,2) b = (a>1) # np.array([[False,True],[True,True]]) How would a[b,np.newaxis] be supposed to work? Note that other (simple) slices work perfectly with newaxis, such as a[:1,np.new

[Numpy-discussion] Can't mix np.newaxis with boolean indexing

2011-08-19 Thread Benjamin Root
I could have sworn that this use to work: import numpy as np a = np.random.random((100,)) b = (a > 0.5) print a[b, np.newaxis] But instead, I get this error on the latest master: Traceback (most recent call last): File "", line 1, in TypeError: long() argument must be a string or a number, no