-
-
Notifications
You must be signed in to change notification settings - Fork 25.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC Investigate scipy-doctest for more convenient doctests #29027
Comments
If there's still interest in scipy-doctest, feel free to ping me |
Thanks! There is still some interest, I did have a quick go at one point but failed to make it work in the amount of time I had 😅 Maybe you can comment on the general approach? In particular, I am guessing that you can still run the previous doctests unchanged with scipy-doctest? Otherwise I guess I (or someone else) would need to look at how numpy or scipy is doing it and adapt it for scikit-learn (for example we already have some logic to skip all doctests for numpy<2 or if matplotlib is not installed): After a quick look it looks like the main things are:
|
Yes, the goal is to be able to run doctests unmodified and make them whitespace insensitive, be able to use To set it up:
When The bulk of scipy/numpy conftest.py is indeed,
Yes, that. And we just like to filter out irrelevant known warnings in some cases. Those parts are not essential.
Indeed. The list of things to skip is kept in the tool, not in the docstrings. Because this is irrelevant to a reader of the docs, or a function is deprecated (so its import emits a DeprecationWarning) etc.
Yes, service parts of the library. In numpy, it's distutils for example; in scipy's dev.py, there's an additional list. I don't know if scikit-learn has ReST tutorials. If you do and if you want them to be doctested, numpy has If you want, we can have a chat in real time. |
Also, while we're on "general approach" topic: the setup in both scipy and numpy is to maintain a clear separation between doctests and actual unit testing. For one, |
Thanks a lot for the details, I need to take a closer look and I'll definitely ping you if I get stuck. |
Turns out it was slightly easier than anticipated, I opened #30496 which seems to work well enough and do not require any changes to our doctests. For now, it seems like we don't need as many tweaks as numpy or scipy, which is good. The next step would be to open a meta-issue to invite contributors clean things up, one file at a time to remove |
Yay, great! Re removing |
I learned about scipy-doctest recent release in the Scientific Python Discourse announcement. Apparently, scipy-doctest has been used internally in numpy and scipy for doctests for some time. In particular it allows floating point comparisons.
After a bit of work from us setting everything up, it would allow to have a few sprint / first good issues.
There is quite a few places where we used the doctest ellipsis, the quick and dirty following regexp finds 595 lines:
If you are not sure what I am talking about, this is the
...
for doctest in rst for docstrings e.g. the last line of this snippet:An example of a doctest with a spurious failure recently: #29140 (comment)
If you are wondering about the difference to pytest-doctestplus look at this. This does seem a bit unfortunate to have
scipy/scipy_doctest
andscientific-python/pytest-doctestplus
but oh well (full disclosure I did not have time to look into the history) ...The text was updated successfully, but these errors were encountered: