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
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
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
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
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