diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2018-01-11 22:07:56 -0800 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2018-02-16 13:40:46 -0700 |
commit | 453bf655b94d936dd17f3f29974698716548641d (patch) | |
tree | c05a48a30d7beb560dfc5aff223a6bcd8a360d99 | |
parent | 7311b961a6827abdee8179cf40f3ab4a2b682408 (diff) | |
download | numpy-453bf655b94d936dd17f3f29974698716548641d.tar.gz |
BUG: Show the base of a compound dtype even when it doesn't subclass void
-rw-r--r-- | numpy/core/src/multiarray/descriptor.c | 4 | ||||
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c index 80161b71c..897155238 100644 --- a/numpy/core/src/multiarray/descriptor.c +++ b/numpy/core/src/multiarray/descriptor.c @@ -3340,8 +3340,8 @@ arraydescr_struct_str(PyArray_Descr *dtype, int includealignflag) sub = arraydescr_struct_dict_str(dtype, includealignflag); } - /* If the data type has a non-void (subclassed) type, show it */ - if (dtype->type_num == NPY_VOID && dtype->typeobj != &PyVoidArrType_Type) { + /* If the data type isn't the default, void, show it */ + if (dtype->typeobj != &PyVoidArrType_Type) { /* * Note: We cannot get the type name from dtype->typeobj->tp_name * because its value depends on whether the type is dynamically or diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 97d28767b..4c52d4bc2 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -478,6 +478,11 @@ class TestDtypedescr(object): assert_(np.dtype('<i4') != np.dtype('>i4')) assert_(np.dtype([('a', '<i4')]) != np.dtype([('a', '>i4')])) + def test_structured_non_void(self): + fields = [('a', '<i2'), ('b', '<i2')] + dt_int = np.dtype(('i4', fields)) + assert_equal(str(dt_int), "(numpy.int32, [('a', '<i2'), ('b', '<i2')])") + class TestZeroRank(object): def setup(self): |