diff options
author | Antony Lee <anntzer.lee@gmail.com> | 2021-09-29 20:09:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-29 13:09:32 -0500 |
commit | a6f7d14e60e3d56fe1c0073730a06e23cf696c5a (patch) | |
tree | 4f836f1bb7532f7b9265f9d07a868a61c4e79bbe /doc | |
parent | e7f5d62f793379a62d1c351eedaa3a59f6f542d5 (diff) | |
download | numpy-a6f7d14e60e3d56fe1c0073730a06e23cf696c5a.tar.gz |
ENH: Add spaces after punctuation in dtype repr/str. (#19686)
Before:
```
In [1]: np.dtype({"names": ["a"], "formats": [int], "offsets": [2]})
Out[1]: dtype({'names':['a'], 'formats':['<i8'], 'offsets':[2], 'itemsize':10})
```
After:
```
In [1]: np.dtype({"names": ["a"], "formats": [int], "offsets": [2]})
Out[1]: dtype({'names': ['a'], 'formats': ['<i8'], 'offsets': [2], 'itemsize': 10})
```
* Allow switching back to old dtype printing format.
* Add changelog.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/release/upcoming_changes/19687.change.rst | 8 | ||||
-rw-r--r-- | doc/source/user/basics.rec.rst | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/doc/release/upcoming_changes/19687.change.rst b/doc/release/upcoming_changes/19687.change.rst new file mode 100644 index 000000000..c7f7512b6 --- /dev/null +++ b/doc/release/upcoming_changes/19687.change.rst @@ -0,0 +1,8 @@ +str/repr of complex dtypes now include space after punctuation +-------------------------------------------------------------- + +The repr of ``np.dtype({"names": ["a"], "formats": [int], "offsets": [2]})`` is +now ``dtype({'names': ['a'], 'formats': ['<i8'], 'offsets': [2], 'itemsize': 10})``, +whereas spaces where previously omitted after colons and between fields. + +The old behavior can be restored via ``np.set_printoptions(legacy="1.21")``. diff --git a/doc/source/user/basics.rec.rst b/doc/source/user/basics.rec.rst index 0524fde8e..1e6f30506 100644 --- a/doc/source/user/basics.rec.rst +++ b/doc/source/user/basics.rec.rst @@ -128,7 +128,7 @@ summary they are: ... 'formats': ['i4', 'f4'], ... 'offsets': [0, 4], ... 'itemsize': 12}) - dtype({'names':['col1','col2'], 'formats':['<i4','<f4'], 'offsets':[0,4], 'itemsize':12}) + dtype({'names': ['col1', 'col2'], 'formats': ['<i4', '<f4'], 'offsets': [0, 4], 'itemsize': 12}) Offsets may be chosen such that the fields overlap, though this will mean that assigning to one field may clobber any overlapping field's data. As |