[pypy-issue] [issue1118] numpypy: indexing of 2D arrays with 1-D boolean arrays is broken

Alan Derk tracker at bugs.pypy.org
Mon Apr 9 04:27:39 CEST 2012


New submission from Alan Derk <streblo at gmail.com>:

Indexing of 1D arrays using boolean arrays works the same as CPython/numpy, but the analogue for 2D arrays is broken (as 
compared to CPython/numpy). The output of both is shown below. Thank you very much developers!!!

Python 2.7.2 (0e28b379d8b3, Feb 09 2012, 18:31:47)
[PyPy 1.8.0 with MSC v.1500 32 bit] on win32
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``first they laugh at you, then
they ignore you, then they fight you, then you win''
>>>> import numpypy as np
>>>> a = np.array([[1,2,3],[4,5,6],[7,8,9]],int)
>>>> b = np.array([7,8,9],int)
>>>> c = np.array([True,False,True],bool)
>>>> b[c]
array([7, 9])
>>>> a[c]
Traceback (most recent call last):
  File "<console>", line 1, in <module>
IndexError: invalid index


Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> a = np.array([[1,2,3],[4,5,6],[7,8,9]],int)
>>> b = np.array([7,8,9],int)
>>> c = np.array([True,False,True],bool)
>>> b[c]
array([7, 9])
>>> a[c]
array([[1, 2, 3],
       [7, 8, 9]])

----------
messages: 4203
nosy: pypy-issue, streblo
priority: bug
status: unread
title: numpypy: indexing of 2D arrays with 1-D boolean arrays is broken

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1118>
________________________________________


More information about the pypy-issue mailing list