diff options
author | Allan Haldane <allan.haldane@gmail.com> | 2015-01-22 15:32:38 -0500 |
---|---|---|
committer | Allan Haldane <allan.haldane@gmail.com> | 2015-01-24 12:05:40 -0500 |
commit | 86efa7dcc6e37dd35ac1ed9dbdcea19637670b50 (patch) | |
tree | dcd8e6f2edb2c4c1af7b12fdcc934ce5d5613ae0 /numpy/polynomial/polyutils.py | |
parent | b69035e8ea28bd759b929822aaba544d3c5f8c30 (diff) | |
download | numpy-86efa7dcc6e37dd35ac1ed9dbdcea19637670b50.tar.gz |
ENH: Show subclass type in dtype repr and str of structured arrays
This is a modification to the dtype str and repr functions what helps
solve https://github.com/numpy/numpy/issues/3581.
I discussed it on the mailing list in a message "Re: structured arrays,
recarrays, and record arrays" on Jan 19 2015. I didn't get any replies,
but hopefully that merely means "no opinion" rather than "bad idea".
What it does: For structured arrays, if the dtype is not np.void then
print the dtype as `(base_dtype, dtype)`.
New Behavior:
>>> a = np.array([(1,'ABC'), (2, "DEF")], dtype=[('foo', int), ('bar', 'S4')])
>>> np.rec.array(a)
rec.array([(1, 'ABC'), (2, 'DEF')],
dtype=(numpy.record, [('foo', '<i8'), ('bar', 'S4')]))
>>> a.view(np.recarray)
rec.array([(1, 'ABC'), (2, 'DEF')],
dtype=[('foo', '<i8'), ('bar', 'S4')])
Diffstat (limited to 'numpy/polynomial/polyutils.py')
0 files changed, 0 insertions, 0 deletions