@@ -318,7 +318,7 @@ $ spin smoke-tutorials # ReST user guide tutorials
318
318
319
319
Here is a (non-exhaustive) list of possible gotchas:
320
320
321
- - _ In-place development builds_ .
321
+ #### _ In-place development builds_ .
322
322
323
323
Some tools (looking at you ` meson-python ` ) simulate in-place builds with a
324
324
` build-install ` directory. If this directory is located under the project root,
@@ -342,7 +342,7 @@ If push really comes to shove, you may try using the magic env variable:
342
342
however the need usually indicates an issue with the package itself.
343
343
(see [ gh-107 ] ( https://github.com/scipy/scipy_doctest/pull/107 ) for an example).
344
344
345
- - _ Optional dependencies are not that optional_
345
+ #### _ Optional dependencies are not that optional_
346
346
347
347
If your package contains optional dependencies, doctests do not know about them
348
348
being optional. So you either guard the imports in doctests (yikes!), or
@@ -361,7 +361,7 @@ Note that installed packages are no different:
361
361
$ pytest --pyargs scipy --doctest-modules --ignore=/path/to/installed/scipy/_lib
362
362
```
363
363
364
- - _ Doctest collection strategies_
364
+ #### _ Doctest collection strategies_
365
365
366
366
The default collection strategy follows ` doctest ` module and ` pytest ` . This leads
367
367
to duplicates if your package has the split between public and \_ private modules,
@@ -383,7 +383,7 @@ leads to
383
383
- ` scipy.linalg._basic.det ` , collected from ` scipy/linalg/_basic.py ` , is private.
384
384
- ` scipy.linalg.det ` , collected from ` scipy/linalg/__init__.py ` , is public.
385
385
386
- - _ ` pytest ` 's assertion rewriting_
386
+ #### _ ` pytest ` 's assertion rewriting_
387
387
388
388
In some rare cases you may need to either explicitly register the ` scipy_doctest `
389
389
package with the ` pytest ` assertion rewriting machinery, or ask it to avoid rewriting
@@ -395,6 +395,21 @@ In general, rewriting assertions is not very useful for doctests, as the
395
395
output on error is fixed by the doctest machinery anyway. Therefore, we believe
396
396
adding ` --assert=plain ` is reasonable.
397
397
398
+ #### _ Mixing strings and numbers_
399
+
400
+ Generally, we aim to handle mixtures of strings and numeric data. Deeply nested data
401
+ structures however may cause the checker to fall back to the vanilla ` doctest ` literal
402
+ checking. For instance, ` ["value", 1/3] ` will use the floating-point aware checker, and
403
+ so will ` {"value": 1/3, "other value": 2/3} ` or ` [(1, 2), (3, 4)] ` ; Meanwhile, nested
404
+ dictionaries, ` {"a": dict(value=1/3)} ` , or lists of tuples with mixed entries,
405
+ ` [("a", 1/3), ("b", 2/3)] ` , will currently fall back to vanilla ` doctest ` literal
406
+ comparisons.
407
+
408
+ We stress that no matter how tricky or deeply nested the output is, the worst case
409
+ scenario is that the floating-point aware checker is not used. If you have a case where
410
+ ` doctest ` works correctly and ` scipy_doctest ` does not, please report it as a bug.
411
+
412
+
398
413
## Prior art and related work
399
414
400
415
- ` pytest ` provides some limited floating-point aware ` NumericLiteralChecker ` .
@@ -417,15 +432,15 @@ adding `--assert=plain` is reasonable.
417
432
functionality, and uses an AST-based analysis to parse code examples out of docstrings.
418
433
419
434
- ` NumPy ` and ` SciPy ` were using modified doctesting in their ` refguide-check ` utilities.
420
- These utilities are tightly coupled to their libraries, and have been reported
435
+ These utilities were tightly coupled to their libraries, and have been reported
421
436
to be not easy to reason about, work with, and extend to other projects.
422
437
423
- This project is mainly the core functionality of the modified
424
- ` refguide-check ` doctesting, extracted to a separate package.
425
- We believe having it separate simplifies both addressing the needs of these
426
- two packages, and potential adoption by other projects.
438
+ This project is mainly the core functionality of the modified ` refguide-check ` doctesting,
439
+ extracted to a separate package. We believe having it separate simplifies both
440
+ addressing the needs of these two packages, and adoption by other projects.
441
+
427
442
428
- ### Bug reports, feature requests and contributions
443
+ ## Bug reports, feature requests and contributions
429
444
430
445
This package is work in progress. Contributions are most welcome!
431
446
Please don't hesitate to open an issue in the tracker or send a pull request.
0 commit comments