diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2018-09-11 22:16:22 -0700 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2018-09-11 22:53:20 -0700 |
commit | cbded8fc37f05908a0243d36a18bddfd8e24e6cd (patch) | |
tree | b7779deb415eb90ace4cb6964f1923df90f37890 /numpy | |
parent | 16a029e37941a211f28f3910159e6ae85a0a5b8b (diff) | |
download | numpy-cbded8fc37f05908a0243d36a18bddfd8e24e6cd.tar.gz |
MAINT: Eliminate a struct/non-struct branch in dtype.__repr__
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/_dtype.py | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/numpy/core/_dtype.py b/numpy/core/_dtype.py index 5047e194a..26c44eaaf 100644 --- a/numpy/core/_dtype.py +++ b/numpy/core/_dtype.py @@ -20,10 +20,10 @@ def __str__(dtype): def __repr__(dtype): - if dtype.fields is not None: - return _struct_repr(dtype) - else: - return "dtype({})".format(_construction_repr(dtype, include_align=True)) + arg_str = _construction_repr(dtype, include_align=False) + if dtype.isalignedstruct: + arg_str = arg_str + ", align=True" + return "dtype({})".format(arg_str) def _unpack_field(dtype, offset, title=None): @@ -292,15 +292,6 @@ def _subarray_str(dtype): ) -def _struct_repr(dtype): - s = "dtype(" - s += _struct_str(dtype, include_align=False) - if dtype.isalignedstruct: - s += ", align=True" - s += ")" - return s - - def _name_get(dtype): # provides dtype.name.__get__ |