summaryrefslogtreecommitdiff
path: root/numpy/doc/structured_arrays.py
diff options
context:
space:
mode:
authorAllan Haldane <allan.haldane@gmail.com>2015-01-29 12:54:25 -0500
committerAllan Haldane <allan.haldane@gmail.com>2015-01-30 11:25:39 -0500
commit73a74e9e9515ad76d652e998fc1e88074e8cd820 (patch)
tree98fec161818c717ed1fa60f7e75a1ba8ae7209c6 /numpy/doc/structured_arrays.py
parent8149c36abb651480202ff55a9b80efda9278be0f (diff)
downloadnumpy-73a74e9e9515ad76d652e998fc1e88074e8cd820.tar.gz
BUG: recarray __repr__ gives inaccurate representation
In https://github.com/numpy/numpy/pull/5483, I solved the problem that a "recarray" and a "record array" (nomenclature defined in https://github.com/numpy/numpy/pull/5482) looked identical by making sure that a type's subclass was listed in the repr. However, recarrays are still represented using the function 'rec.array' even though this function technically creates record arrays, not recarrays. So I have updated recarray.__repr__. Setup: >>> a = np.array([(1,'ABC'), (2, "DEF")], dtype=[('foo', int), ('bar', 'S4')]) >>> recordarr = np.rec.array(a) >>> recarr = a.view(np.recarray) Behavior after https://github.com/numpy/numpy/pull/5483: >>> recordarr rec.array([(1, 'ABC'), (2, 'DEF')], dtype=(numpy.record, [('foo', '<i8'), ('bar', 'S4')])) >>> recarr rec.array([(1, 'ABC'), (2, 'DEF')], dtype=[('foo', '<i8'), ('bar', 'S4')]) New Behavior: >>> recordarr rec.array([(1, 'ABC'), (2, 'DEF')], dtype=[('foo', '<i8'), ('bar', '|S4')]) >>> recarr array([(1, 'ABC'), (2, 'DEF')], dtype=[('foo', '<i8'), ('bar', 'S4')]).view(numpy.recarray)
Diffstat (limited to 'numpy/doc/structured_arrays.py')
-rw-r--r--numpy/doc/structured_arrays.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/numpy/doc/structured_arrays.py b/numpy/doc/structured_arrays.py
index d8b4fc719..73bf3b317 100644
--- a/numpy/doc/structured_arrays.py
+++ b/numpy/doc/structured_arrays.py
@@ -292,7 +292,7 @@ such a view do not have field attributes::
To use the np.record dtype only, convert the dtype using the (base_class,
dtype) form described in numpy.dtype. This type of view is rarely used. ::
- >>> arr_records = arr.view(dtype(np.record, arr.dtype))
+ >>> arr_records = arr.view(dtype((np.record, arr.dtype)))
In documentation, the term 'structured array' will refer to objects of type
np.ndarray with structured dtype, 'record array' will refer to structured