diff options
Diffstat (limited to 'numpy/core/arrayprint.py')
-rw-r--r-- | numpy/core/arrayprint.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 3554fe3c4..929f55f5a 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -1254,6 +1254,11 @@ def dtype_is_implied(dtype): dtype = np.dtype(dtype) if _format_options['legacy'] == '1.13' and dtype.type == bool_: return False + + # not just void types can be structured, and names are not part of the repr + if dtype.names is not None: + return False + return dtype.type in _typelessdata @@ -1266,12 +1271,12 @@ def dtype_short_repr(dtype): >>> from numpy import * >>> assert eval(dtype_short_repr(dt)) == dt """ - # handle these separately so they don't give garbage like str256 - if issubclass(dtype.type, flexible): - if dtype.names is not None: - return "%s" % str(dtype) - else: - return "'%s'" % str(dtype) + if dtype.names is not None: + # structured dtypes give a list or tuple repr + return str(dtype) + elif issubclass(dtype.type, flexible): + # handle these separately so they don't give garbage like str256 + return "'%s'" % str(dtype) typename = dtype.name # quote typenames which can't be represented as python variable names |