refguide-check fails on master
See original GitHub issueRecent PRs fail the refguide-check CI run, e.g. https://travis-ci.org/scipy/scipy/jobs/422178274
Most failures are due to some changes in the amount of whitespace numpy decides to use when printing arrays. Usually, plain doctests are annoying to work with precisely because they tend to fret on whitespace. To counter that, our refguide-check tries to detect floating-point comparisons and delegate them to numpy. It seems that the detection fails in several classes of cases:
- printing n-dim arrays. We added some logic for detection of the result of printing an array in gh-9178, but it does not handle ndim>1.
For example:
File "build/testenv/lib/python3.6/site-packages/scipy/cluster/hierarchy.py", line 1788, in inconsistent
Failed example:
print(Z)
Expected:
[[ 5. 6. 0. 2. ]
[ 2. 7. 0. 2. ]
[ 0. 4. 1. 2. ]
[ 1. 8. 1.15470054 3. ]
[ 9. 10. 2.12132034 4. ]
[ 3. 12. 4.11096096 5. ]
[11. 13. 14.07183949 8. ]]
Got:
[[ 5. 6. 0. 2. ]
[ 2. 7. 0. 2. ]
[ 0. 4. 1. 2. ]
[ 1. 8. 1.15470054 3. ]
[ 9. 10. 2.12132034 4. ]
[ 3. 12. 4.11096096 5. ]
[ 11. 13. 14.07183949 8. ]]
The simplest way of fixing these is probably to change in the examples, >>> print(Z) to just >>> Z
Otherwise, the relevant logic is https://github.com/scipy/scipy/blob/master/tools/refguide_check.py#L570
- Somewhat trickier: numpy arrays hidden in textual output. Note the whitespace in the
slackandxarrays.
scipy.optimize.linprog
----------------------
File "build/testenv/lib/python3.6/site-packages/scipy/optimize/_linprog.py", line 1059, in linprog
Failed example:
print(res)
Expected:
fun: -22.0
message: 'Optimization terminated successfully.'
nit: 1
slack: array([39., 0.])
status: 0
success: True
x: array([10., -3.])
Got:
fun: -22.0
message: 'Optimization terminated successfully.'
nit: 1
slack: array([ 39., 0.])
status: 0
success: True
x: array([ 10., -3.])
Maybe it’s best to just change doctest output. Alternatively, one can teach the doctester to search for array([<whatever>]).
- namedtuples and similar objects:
File "build/testenv/lib/python3.6/site-packages/scipy/stats/morestats.py", line 97, in bayes_mvs
Failed example:
std
Expected:
Std_dev(statistic=2.9724954732045084, minmax=(1.7823367265645143, 4.945614605014631))
Got:
Std_dev(statistic=2.9724954732045084, minmax=(1.7823367265645143, 4.9456146050146312))
Again, there’s some rudimentary logic for handling these sorts of issues, https://github.com/scipy/scipy/blob/master/tools/refguide_check.py#L587 but it is also too simplistic.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (8 by maintainers)

Top Related StackOverflow Question
We fixed the printing to latest numpy format in gh-8279, so I think we only need to tell CI to use latest numpy: gh-9202
I think we aim to target the refguide to the numpy output as it is in the latest version.