scipy-doctest 1.4__py3-none-any.whl → 1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
scipy_doctest/__init__.py CHANGED
@@ -3,7 +3,7 @@ Configurable, whitespace-insensitive, floating-point-aware doctest helpers.
3
3
  """
4
4
 
5
5
 
6
- __version__ = "1.4"
6
+ __version__ = "1.5"
7
7
 
8
8
  try:
9
9
  # register internal modules with pytest; obscure errors galore otherwise
scipy_doctest/impl.py CHANGED
@@ -148,8 +148,12 @@ class DTConfig:
148
148
  'masked_array': np.ma.masked_array,
149
149
  'int64': np.int64,
150
150
  'uint64': np.uint64,
151
- 'int8': np.int8,
152
151
  'int32': np.int32,
152
+ 'uint32': np.uint32,
153
+ 'int16': np.int16,
154
+ 'uint16': np.uint16,
155
+ 'int8': np.int8,
156
+ 'uint8': np.uint8,
153
157
  'float32': np.float32,
154
158
  'float64': np.float64,
155
159
  'dtype': np.dtype,
@@ -262,6 +266,29 @@ def has_masked(got):
262
266
  return 'masked_array' in got and '--' in got
263
267
 
264
268
 
269
+ def try_split_shape_from_abbrv(s_got):
270
+ """NumPy 2.2 added shape=(123,) to abbreviated array repr.
271
+
272
+ If present, split it off, and return a tuple. `(array, shape)`
273
+ """
274
+ if "shape=" in s_got:
275
+ # handle
276
+ # array(..., shape=(1000,))
277
+ # array(..., shape=(100, 100))
278
+ # array(..., shape=(100, 100), dtype=uint16)
279
+ match = re.match(r'(.+),\s+shape=\(([\d\s,]+)\)(.+)', s_got, flags=re.DOTALL)
280
+ if match:
281
+ grp = match.groups()
282
+
283
+ s_got = grp[0] + grp[-1]
284
+ s_got = s_got.replace(',,', ',')
285
+ shape_str = f'({grp[1]})'
286
+
287
+ return ''.join(s_got.split('...,')), shape_str
288
+
289
+ return ''.join(s_got.split('...,')), ''
290
+
291
+
265
292
  class DTChecker(doctest.OutputChecker):
266
293
  obj_pattern = re.compile(r'at 0x[0-9a-fA-F]+>')
267
294
  vanilla = doctest.OutputChecker()
@@ -325,11 +352,17 @@ class DTChecker(doctest.OutputChecker):
325
352
  return self.check_output(s_want, s_got, optionflags)
326
353
 
327
354
  #handle array abbreviation for n-dimensional arrays, n >= 1
328
- ndim_array = (s_want.startswith("array([") and s_want.endswith("])") and
329
- s_got.startswith("array([") and s_got.endswith("])"))
355
+ ndim_array = (s_want.startswith("array([") and "..." in s_want and
356
+ s_got.startswith("array([") and "..." in s_got)
330
357
  if ndim_array:
331
- s_want = ''.join(s_want.split('...,'))
332
- s_got = ''.join(s_got.split('...,'))
358
+ s_want, want_shape = try_split_shape_from_abbrv(s_want)
359
+ s_got, got_shape = try_split_shape_from_abbrv(s_got)
360
+
361
+ if got_shape:
362
+ # NumPy 2.2 output, `with shape=`, check the shapes, too
363
+ s_want = f"{s_want}, {want_shape}"
364
+ s_got = f"{s_got}, {got_shape}"
365
+
333
366
  return self.check_output(s_want, s_got, optionflags)
334
367
 
335
368
  # maybe we are dealing with masked arrays?
@@ -164,14 +164,25 @@ def array_abbreviation():
164
164
  """
165
165
  Numpy abbreviates arrays, check that it works.
166
166
 
167
- NB: the implementation might need to change when
168
- numpy finally disallows default-creating ragged arrays.
169
- Currently, `...` gets interpreted as an Ellipsis,
170
- thus the `a_want/a_got` variables in DTChecker are in fact
171
- object arrays.
167
+ XXX: check if ... creates ragged arrays, avoid if so.
168
+
169
+ NumPy 2.2 abbreviations
170
+ =======================
171
+
172
+ NumPy 2.2 adds shape=(...) to abbreviated arrays.
173
+
174
+ This is not a valid argument to `array(...), so it cannot be eval-ed,
175
+ and need to be removed for doctesting.
176
+
177
+ The implementation handles both formats, and checks the shapes if present
178
+ in the actual output. If not present in the output, they are ignored.
179
+
172
180
  >>> import numpy as np
173
181
  >>> np.arange(10000)
174
- array([0, 1, 2, ..., 9997, 9998, 9999])
182
+ array([0, 1, 2, ..., 9997, 9998, 9999], shape=(10000,))
183
+
184
+ >>> np.arange(10000, dtype=np.uint16)
185
+ array([ 0, 1, 2, ..., 9997, 9998, 9999], shape=(10000,), dtype=uint16)
175
186
 
176
187
  >>> np.diag(np.arange(33)) / 30
177
188
  array([[0., 0., 0., ..., 0., 0.,0.],
@@ -180,19 +191,20 @@ def array_abbreviation():
180
191
  ...,
181
192
  [0., 0., 0., ..., 1., 0., 0.],
182
193
  [0., 0., 0., ..., 0., 1.03333333, 0.],
183
- [0., 0., 0., ..., 0., 0., 1.06666667]])
194
+ [0., 0., 0., ..., 0., 0., 1.06666667]], shape=(33, 33))
184
195
 
185
196
 
186
- >>> np.diag(np.arange(1, 1001, dtype=float))
197
+ >>> np.diag(np.arange(1, 1001, dtype=np.uint16))
187
198
  array([[1, 0, 0, ..., 0, 0, 0],
188
199
  [0, 2, 0, ..., 0, 0, 0],
189
200
  [0, 0, 3, ..., 0, 0, 0],
190
201
  ...,
191
202
  [0, 0, 0, ..., 998, 0, 0],
192
203
  [0, 0, 0, ..., 0, 999, 0],
193
- [0, 0, 0, ..., 0, 0, 1000]])
204
+ [0, 0, 0, ..., 0, 0, 1000]], shape=(1000, 1000), dtype=uint16)
194
205
  """
195
206
 
207
+
196
208
  def nan_equal():
197
209
  """
198
210
  Test that nans are treated as equal.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: scipy_doctest
3
- Version: 1.4
3
+ Version: 1.5
4
4
  Summary: Configurable, whitespace-insensitive, floating-point-aware doctest helpers.
5
5
  Maintainer-email: SciPy developers <scipy-dev@python.org>
6
6
  Requires-Python: >=3.8
@@ -1,8 +1,8 @@
1
- scipy_doctest/__init__.py,sha256=IyY6n7Dj46DJxtsOi2DOMvw4NDmIWOJSIT9Mx97Szvk,649
1
+ scipy_doctest/__init__.py,sha256=uRFgqX-BvUtGq2GVDAAGjdF5A7JfD-scaE0-D6xJZaY,649
2
2
  scipy_doctest/__main__.py,sha256=H8jTO13GlOLzexbgu7lHMJW1y3_NhLOSArARFZ5WS7o,90
3
3
  scipy_doctest/conftest.py,sha256=5vZxzuH042urYIToiKWANDJHQPoGkfQI-ppQ_cuHgM0,53
4
4
  scipy_doctest/frontend.py,sha256=7Vz9VIRmzdkmwPD1OtI9sJSxCXIF7jmSxXyt6asjaI0,18628
5
- scipy_doctest/impl.py,sha256=tYJnNBuBBwdrnxyk8iy07qucTQGa5TzLqGEuFNNNzNU,22980
5
+ scipy_doctest/impl.py,sha256=NC61Qy-4VXd3Vjk9WXyTf0oPcm6ZdIiv7WxeVSffTrw,24083
6
6
  scipy_doctest/plugin.py,sha256=DzTPBCDIre5b2e8JLiTGw7d9zhCP9hYqXcxeKpFTtys,12900
7
7
  scipy_doctest/util.py,sha256=R-pS9FSL5hQNmOA0nhRDLOL1riFVAoK-OhG70ilaKhw,8057
8
8
  scipy_doctest/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -11,7 +11,7 @@ scipy_doctest/tests/failure_cases_2.py,sha256=gupqwSICvzurGIiKVNJRJX9jkmtFR7_Rf3
11
11
  scipy_doctest/tests/finder_cases.py,sha256=s4sq5HZ7m5mXEi1N8dbkgCRY6AxEGcirFRYhEyEG7rw,872
12
12
  scipy_doctest/tests/local_file.txt,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  scipy_doctest/tests/local_file_cases.py,sha256=xQeD809EoLxY-QIb0X7ZPl6Ecyme3zjnf95AHJ_8gp0,914
14
- scipy_doctest/tests/module_cases.py,sha256=Ui3rjM0a08rQE28w2Wl_pMs4aWshOL_MkrIVm49KXs0,5470
14
+ scipy_doctest/tests/module_cases.py,sha256=W3u97oMJ8yf0rqrsiQbB1yMMTkKAVz4gNpBLDhijHek,5860
15
15
  scipy_doctest/tests/octave_a.mat,sha256=lOfXBSOdMG7_kruTnOHjixXkPy3zSUt10A1FSVjfngI,288
16
16
  scipy_doctest/tests/scipy_ndimage_tutorial_clone.rst,sha256=uCtH99RQM0hvDK2_5lgBO2hqtMUOUQhPKxWn4zwHjSs,81594
17
17
  scipy_doctest/tests/stopwords_cases.py,sha256=OEZkoFW3B9nHUCG_5adSkLI91avSwNjw-NeUS0D6Yz0,156
@@ -22,8 +22,8 @@ scipy_doctest/tests/test_runner.py,sha256=qP4u8ngbUK946HhMM6Py70hi0W0DcZGcCN258p
22
22
  scipy_doctest/tests/test_skipmarkers.py,sha256=C5U8BKF3Ti-nPWekt2yK6a3j3Tcg_pq-Z5IuiR-F9eU,7835
23
23
  scipy_doctest/tests/test_testfile.py,sha256=66ZHUpEGGg8MfQT8EKSZ8Zx5pV55gP__TZejGMYwBHA,733
24
24
  scipy_doctest/tests/test_testmod.py,sha256=PoOI0o2_dXjWDmDkUUKqcJiyZvh46YpjlmMxyW6PXyI,5874
25
- scipy_doctest-1.4.dist-info/entry_points.txt,sha256=dFda3z6PjFL7pEWokv_QmoLwE8X1HETCY1H60xopQ-s,47
26
- scipy_doctest-1.4.dist-info/LICENSE,sha256=xH5PVX8bm8e1JxkmJ-e5FsZsOa7FsNOMfepmCvMoR9g,1523
27
- scipy_doctest-1.4.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
28
- scipy_doctest-1.4.dist-info/METADATA,sha256=y5qj7KF7WLeVmI37bLi0v0MCUzWJY-z1c8UmaDyGhnM,14867
29
- scipy_doctest-1.4.dist-info/RECORD,,
25
+ scipy_doctest-1.5.dist-info/entry_points.txt,sha256=dFda3z6PjFL7pEWokv_QmoLwE8X1HETCY1H60xopQ-s,47
26
+ scipy_doctest-1.5.dist-info/LICENSE,sha256=xH5PVX8bm8e1JxkmJ-e5FsZsOa7FsNOMfepmCvMoR9g,1523
27
+ scipy_doctest-1.5.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
28
+ scipy_doctest-1.5.dist-info/METADATA,sha256=tAedM4-9Ya3w0fB-B6XoUxXCq7cY-BLo4jUvR__XJOA,14867
29
+ scipy_doctest-1.5.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: flit 3.9.0
2
+ Generator: flit 3.10.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any