[NumPy-Tickets] [NumPy] #1948: chararray subscription returns empty string instead of empty list
NumPy Trac
numpy-tickets@scipy....
Sun Mar 25 10:59:51 CDT 2012
#1948: chararray subscription returns empty string instead of empty list
------------------------------------+---------------------------------------
Reporter: jazzer | Owner: somebody
Type: defect | Status: needs_review
Priority: normal | Milestone: 1.7.0
Component: numpy.core | Version: 1.5.1
Keywords: chararray empty string |
------------------------------------+---------------------------------------
Comment(by rgommers):
The proposed fix (returning []) is consistent with how plain arrays with
string dtypes work:
{{{
>>> >>> s = np.array(['a', 'bb', 'cc'], dtype='S4')
>>> >>> s[[]]
array([],
dtype='|S4')
>>>
>>> >>> a =
np.rec.array([("a",1),("bb",2),("cc",3)],dtype=[('s','|S4'),('n','i4')])
>>> >>> a.s[[]]
[]
>>>
>>> >>> s == a.s
array([ True, True, True], dtype=bool)
>>>
>>> >>> type(s)
<type 'numpy.ndarray'>
>>> >>> type(a.s)
<class 'numpy.core.defchararray.chararray'>
}}}
The proposed fix does break another test though:
{{{
======================================================================
FAIL: test_expandtabs (test_defchararray.TestMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/rgommers/Code/numpy/numpy/core/tests/test_defchararray.py",
line 330, in test_expandtabs
assert_(T[2][0] == asbytes('123 345'))
File "/Users/rgommers/Code/numpy/numpy/testing/utils.py", line 34, in
assert_
raise AssertionError(msg)
AssertionError
}}}
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1948#comment:3>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list