@@ -52,9 +52,9 @@ with the new scheme to use the ``np`` prefix consistently:
52
52
The NEP does not propose to change how these scalars print – only
53
53
their representation (``__repr__ ``) will be changed.
54
54
Further, array representation will not be affected since it already
55
- includes the ``dtype= `` when necessary.
55
+ includes the ``dtype= `` when necessary.
56
56
57
- The main motivation behind the change is that the Python numerical types
57
+ The main motivation behind the change is that the Python numerical types
58
58
behave differently from the NumPy scalars.
59
59
For example numbers with lower precision (e.g. ``uint8 `` or ``float16 ``)
60
60
should be used with care and users should be aware when they are working
@@ -104,6 +104,14 @@ changes. In general we believe that informing users about the type
104
104
they are working with outweighs the need for adapting printing in
105
105
some instances.
106
106
107
+ The NumPy test suite includes code such as ``decimal.Decimal(repr(scalar)) ``.
108
+ This code needs to be modified to use the ```str() ``.
109
+
110
+ .. admonition :: TODO
111
+
112
+ If there is a lot of similar code, we may need a better solution than
113
+ ``str() ``, since it is plausible that ``str() `` should honor
114
+
107
115
An exception to this are downstream libraries with documentation and
108
116
especially documentation testing.
109
117
Since the representation of many values will change, in many cases
@@ -136,7 +144,7 @@ This NEP proposes to change the represenatation for NumPy scalars to:
136
144
``np.longdouble('3.0') ``. This ensures that it can always roundtrip correctly
137
145
and matches ``decimal.Decimal ``.
138
146
Further, for these two the size based name such as ``float128 `` will not
139
- be adopted, as it is platform dependend and imprecise.
147
+ be adopted, as it is platform dependend and imprecise.
140
148
* ``np.str_("string") `` and ``np.bytes_(b"byte_string") `` for string dtypes.
141
149
142
150
Where booleans are printed as their singletons since this is more concise.
@@ -164,6 +172,24 @@ to always print as ``longdouble`` and never ``float128`` or ``float96``.
164
172
It does not include deprecating the ``np.float128 `` alias.
165
173
However, such a deprecation may occur independently of the NEP.
166
174
175
+ Integer scalar type name and instance represenatation
176
+ -----------------------------------------------------
177
+
178
+ One detail is that due to NumPy scalar types being based on the C types,
179
+ NumPy sometimes distinguishes them, for example on most 64 bit systems
180
+ (not windows)::
181
+
182
+ >>> np.longlong
183
+ numpy.longlong
184
+ >>> np.longlong(3)
185
+ np.int64(3)
186
+
187
+ The proposal will lead to the ``longlong `` name for the type while
188
+ using the ``int64 `` form for the scalar.
189
+ This choice is made since ``int64 `` is generally the more useful
190
+ information for users, but the type name itself must be precise.
191
+
192
+
167
193
Related Work
168
194
============
169
195
0 commit comments