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

Benjamin Root ben.root at ou.edu
Fri Aug 19 11:50:50 EDT 2011


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 "<stdin>", line 1, in <module>
TypeError: long() argument must be a string or a number, not 'NoneType'

Note, the simple work-around would be "a[b][:, np.newaxis]", but I can't
imagine why the intuitive syntax would not be valid.

Thanks,
Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110819/f3ec1e2a/attachment.html>


More information about the NumPy-Discussion mailing list