[Numpy-discussion] slicing with boolean in numpy master

josef.pktd@gmai... josef.pktd@gmai...
Wed Jun 26 10:30:04 CDT 2013


Is there a change in the behavior of boolean slicing in current master?

If not I have to find another candidate in numpy master.

(py27d) E:\Josef\testing\tox\py27d\Scripts>python
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.__version__
'1.7.1'
>>> x = np.ones((5,3))
>>> mask = np.arange(5) < 4
>>> x[mask, :]
array([[ 1.,  1.,  1.],
       [ 1.,  1.,  1.],
       [ 1.,  1.,  1.],
       [ 1.,  1.,  1.]])


We get errors like the following when running the statsmodels tests
with a current or recent numpy master, but not with numpy 1.7.1

======================================================================
ERROR: Failure: IndexError (too many indices)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/tom/python2.7/lib/python2.7/site-packages/nose/loader.py",
line 518, in makeTest
    return self._makeTest(obj, parent)
  File "/Users/tom/python2.7/lib/python2.7/site-packages/nose/loader.py",
line 577, in _makeTest
    return MethodTestCase(obj)
  File "/Users/tom/python2.7/lib/python2.7/site-packages/nose/case.py",
line 345, in __init__
    self.inst = self.cls()
  File "/Users/tom/python2.7/lib/python2.7/site-packages/statsmodels-0.5.0-py2.7-macosx-10.8-x86_64.egg/statsmodels/emplike/tests/test_aft.py",
line 19, in __init__
    super(Test_AFTModel, self).__init__()
  File "/Users/tom/python2.7/lib/python2.7/site-packages/statsmodels-0.5.0-py2.7-macosx-10.8-x86_64.egg/statsmodels/emplike/tests/test_aft.py",
line 12, in __init__
    self.mod1 = sm.emplike.emplikeAFT(endog, exog, data.censors)
  File "/Users/tom/python2.7/lib/python2.7/site-packages/statsmodels-0.5.0-py2.7-macosx-10.8-x86_64.egg/statsmodels/emplike/aft_el.py",
line 248, in __init__
    self.uncens_endog = self.endog[np.bool_(self.censors), :].\
IndexError: too many indices

Thanks,

Josef


More information about the NumPy-Discussion mailing list