[Numpy-svn] [numpy/numpy] 3cd9e7: BUG: Fix recarray getattr and getindex return type...
GitHub
noreply at github.com
Mon Jan 26 20:51:58 EST 2015
Branch: refs/heads/master
Home: https://github.com/numpy/numpy
Commit: 3cd9e7339c37880cff0a2f381e881e0e612c4948
https://github.com/numpy/numpy/commit/3cd9e7339c37880cff0a2f381e881e0e612c4948
Author: Allan Haldane <allan.haldane at gmail.com>
Date: 2015-01-26 (Mon, 26 Jan 2015)
Changed paths:
M doc/release/1.10.0-notes.rst
M numpy/core/records.py
M numpy/core/tests/test_records.py
M numpy/doc/structured_arrays.py
Log Message:
-----------
BUG: Fix recarray getattr and getindex return types
This commit makes changes to `__getitem__` and `__getattr__` of recarrays:
1. recarrays no longer convert string ndarrays to chararrays, and
instead simply return ndarrays of string type.
2. attribute access and index access of fields now behaves identically
3. dtype.type is now inherited when fields of structured type are accessed
Demonstration:
>>> rec = np.rec.array([('abc ', (1,1), 1), ('abc', (2,3), 1)],
... dtype=[('foo', 'S4'), ('bar', [('A', int), ('B', int)]), ('baz', int)])
Old Behavior:
>>> type(rec.foo), type(rec['foo'])
(numpy.core.defchararray.chararray, numpy.recarray)
>>> type(rec.bar), type(rec['bar']), rec.bar.dtype.type
(numpy.recarray, numpy.recarray, numpy.void)
>>> type(rec.baz), type(rec['baz'])
(numpy.ndarray, numpy.ndarray)
New behavior:
>>> type(rec.foo), type(rec['foo'])
(numpy.ndarray, numpy.ndarray)
>>> type(rec.bar), type(rec['bar']), rec.bar.dtype.type
(numpy.recarray, numpy.recarray, numpy.record)
>>> type(rec.baz), type(rec['baz'])
(numpy.ndarray, numpy.ndarray)
Commit: fbcc24fa7cedd2bbf25506a0683f89d13f2d4846
https://github.com/numpy/numpy/commit/fbcc24fa7cedd2bbf25506a0683f89d13f2d4846
Author: Charles Harris <charlesr.harris at gmail.com>
Date: 2015-01-26 (Mon, 26 Jan 2015)
Changed paths:
M doc/release/1.10.0-notes.rst
M numpy/core/records.py
M numpy/core/tests/test_records.py
M numpy/doc/structured_arrays.py
Log Message:
-----------
Merge pull request #5505 from ahaldane/recarray_returntype
BUG: Fix recarray getattr and getindex return types
Compare: https://github.com/numpy/numpy/compare/a786c82c312e...fbcc24fa7ced
More information about the Numpy-svn
mailing list