Skip to content

DOC: doctest ReST sources in doc/source/reference #29547

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ev-br
Copy link
Contributor

@ev-br ev-br commented Aug 12, 2025

Prompted by #29544 : Add doctesting of ReST sources in doc/source/reference, which were never doctested IIUC.

This is a minimal fix. Several larger-scale potential improvements are discussed in gh-29544.

ev-br added 3 commits August 12, 2025 14:10
This still misses subdirectories.
Also, some subdirectories (reference/random as an example) use
`.. code-block :: python` and `.. ipython` syntax, which the
doctest finder/parser misses.
There is no good way to show both the result *and* a warning
in the doctesting machinery otherwise.
@mattip
Copy link
Member

mattip commented Aug 12, 2025

LGTM, I guess we know it is working since there is a failing test

=================================== FAILURES ===================================
___________________________ [doctest] array_api.rst ____________________________
039 
040 
041 Entry point
042 ===========
043 
044 NumPy installs an `entry point <https://packaging.python.org/en/latest/specifications/entry-points/>`__
045 that can be used for discovery purposes::
046 
047     >>> from importlib.metadata import entry_points
048     >>> entry_points(group='array_api', name='numpy')
Expected:
    (EntryPoint(name='numpy', value='numpy', group='array_api'),)
Got:
    [EntryPoint(name='numpy', value='numpy', group='array_api')]

/home/circleci/repo/doc/source/reference/array_api.rst:48: DocTestFailure

Using [skip actions][skip azp][skip cirrus] would save some CI cycles

@ev-br ev-br force-pushed the doctest_reference branch from 379a317 to fa44f38 Compare August 12, 2025 14:38
@ev-br
Copy link
Contributor Author

ev-br commented Aug 12, 2025

A proof by a CI failure, as it were :-).

Funny enough, the EntryPoint thing which fails on CI fails locally for me otherwise. So the type depends on versions of something. Am changing it back to whatever passes on CI.

Using [skip actions][skip azp][skip cirrus] would save some CI cycles

Yup, thanks. I keep forgetting the exact syntax in different projects. Maybe it's something to add to the PR template? For me (based on statistics of one!) it'd help to have a link to the relevant section of the docs.

Copy link
Member

@seberg seberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice to add things and fixup the docs.

But I wonder what your opion is on those warnings, or if we can't find an easy fix?
I love running tests with all warnings being turned to errors, but for doc tests this is actually making the documentation worse to bend it to an environment nobody uses in practice.

>>> np.float32(1) + 1e300
Traceback (most recent call last):
...
RuntimeWarning: overflow encountered in cast
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, this seems a tad annoying? Can we change warning settings for doctests to not raise? I think just printing the warning as it was is nicer, because that is what users see!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants