Skip to content

DOC: fix remaining doc files for refguide_check#15720

Merged
mattip merged 12 commits intonumpy:masterfrom
pdebuyl:fix_refguide_rest
Mar 26, 2020
Merged

DOC: fix remaining doc files for refguide_check#15720
mattip merged 12 commits intonumpy:masterfrom
pdebuyl:fix_refguide_rest

Conversation

@pdebuyl
Copy link
Contributor

@pdebuyl pdebuyl commented Mar 7, 2020

Related to #14970

Fix remaining files for refguide_check.

doc/source/f2py/getting-started.rst
doc/source/reference/arrays.nditer.rst
doc/source/user/c-info.python-as-glue.rst

Notes:

  • There remained some formatting issues that I put in separate commits.
  • Most problems stemmed from cython or f2py modules that cannot be compiled on the fly with the current build/test system. Those are skipped, see DOC, TST: check docstrings in doc/*rst files #14970 (comment)
  • There was a separate discrepancy in arrays.nditer.rst where some examples made incorrect use of the "external_loop" flag.
  • In arrays.nditer.rst, the loop output was unintuitive in some places and was fixed by assigning the loop output to a dummy variable, as discussed here: DOC, TST Update doctests ref guide #15519 (comment)

With this PR, python tools/refguide_check.py --rst outputs

OK: all checks passed!

and the sphinx build proceeds without warning (apart from a minor data clipping warning for imshow).

After merging, the NumPy project should consider testing via pytest and suitable plugins, including astropy's pytest-doctestplus, see #15703 (comment) and migrating the doc accordingly.

I test pytest on the files I edited and most errors stemmed from whitespace issues or specific usages (matplotlib functions return a repr for the figure object, those are not included in the current docs).

pdebuyl added 6 commits March 7, 2020 11:29
The external_loop prevent the iterations to go over items, which is not
the intended effect in the document.
This is likely a temporary measure to enable continuous integration
testing of the docs.
This is likely a temporary measure to enable continuous integration
testing of the docs.
Fix whitespace issues.

Fix formatting for current NumPy version.
@mattip
Copy link
Member

mattip commented Mar 15, 2020

Rather than skipping the f2py tests we could theoretically try to execute them:

.. for doctests

  >>> import numpy.f2py, os
  >>> with open('fib1.f') as fid:
  ...     source = fid.read()
  >>> numpy.f2py.compile(source, modulename='fib1')

but this does not work. The doctests are executed in a temporary directory, and have no access to the fib1.f file.

@pdebuyl
Copy link
Contributor Author

pdebuyl commented Mar 15, 2020

I noticed as well.

Running pytest --doctest-glob '*.rst' executes the tests with the path when executing the command as the current working directory for the tests. But this requires replacing refguide_check.py with pytest.

@mattip
Copy link
Member

mattip commented Mar 15, 2020

But this requires replacing refguide_check.py with pytest.

I am OK with skipping all the f2py compilation doctests for now then.

... print(x, end=' ')
...
0 1 2 3 4 5
0 1 2 3 4 5
Copy link
Member

Choose a reason for hiding this comment

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

extra space at the end of the line

@mattip
Copy link
Member

mattip commented Mar 15, 2020

Other than some extra spaces at the end of lines, this looks good to me.

@pdebuyl
Copy link
Contributor Author

pdebuyl commented Mar 15, 2020

Hi @mattip thank you for the feedback. There might be an issue with the end-of-line marker on github. I did put the extra spaces. Did you check with a local copy?

@mattip
Copy link
Member

mattip commented Mar 15, 2020

I did put the extra spaces

We don't really like extra spaces on the end of lines and refguide-check does not require them, so it would be better to remove them.

@pdebuyl
Copy link
Contributor Author

pdebuyl commented Mar 15, 2020

I used pytest to check the spacing of all tests, and the end-of-line space was required here. If we do move to pytest ultimately, those will be required.

Let me know if I should remove them despite this perspective.

@mattip mattip added the triage review Issue/PR to be discussed at the next triage meeting label Mar 16, 2020
@mattip
Copy link
Member

mattip commented Mar 25, 2020

Isn't there a way to skip all the f2py doctests using the SKIPLIST in refguide-check? Also - please remove the spaces at the end of the lines.

@mattip mattip added triaged Issue/PR that was discussed in a triage meeting and removed triage review Issue/PR to be discussed at the next triage meeting labels Mar 25, 2020
@rgommers
Copy link
Member

I agree, a bit of context:

Isn't there a way to skip all the f2py doctests using the SKIPLIST in refguide-check?

This (skiplist) is how it also works in SciPy, and it's nicer because #doctest: SKIP is visual noise in examples (which is what doctests are primarily).

Also - please remove the spaces at the end of the lines.

Rationale: someone else's editor will strip these spaces again. We should just fix the printing behavior if needed (it doesn't really seem needed now).

@pdebuyl
Copy link
Contributor Author

pdebuyl commented Mar 25, 2020

changes done, I tested locally and wait for the CI checks.

Some SKIP remain in arrays.nditer.rst as a small part of that file only relies on a compiled extension. Some examples there also use timeit which is not valid outside of IPython/jupyter

@pdebuyl
Copy link
Contributor Author

pdebuyl commented Mar 25, 2020

@mattip I have addressed the review items.

'doc/source/release',
'c-info.ufunc-tutorial.rst',
'c-info.python-as-glue.rst',
'getting-started.rst',
Copy link
Member

Choose a reason for hiding this comment

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

I got scared for a second, until I realized that gettting-started.rst is not the general beginner guide, rather the one inside the f2py directory. Could you rename the file to f2py.getting-started.rst or something that would prevent a future conflict with a getting-started.rst file for another task?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Here, as a contributor I hesitated to rename a file.

100 loops, best of 3: 11.8 ms per loop

>>> np.all(sum_squares_cy(a, axis=-1) == np.sum(a*a, axis=-1))
>>> np.all(sum_squares_cy(a, axis=-1) == np.sum(a*a, axis=-1)) # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

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

All these skips are annoying. Would it work to

  • split the file in two, move all the cython code to arrays.nditer.cython.rst
  • add arrays.nditer.cython.rst to the skiplist
  • use an .. include:: arrays.nditer.cython.rst so that sphinx will render the documents as before
  • add .. for doctests comments just before the include and at the top of the new file to explain why this was done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tentative update pushed

pdebuyl added 2 commits March 26, 2020 14:56
Place the Cython-dependent section in separate file.

Ignore the new file from the doctests with an RST_SKIPLIST entry in
refguide_check.py
@mattip
Copy link
Member

mattip commented Mar 26, 2020

Looks good now thanks. At some point we should refactor the redundant parts of arrays.nditer.rst and 'nditer' notes.

@mattip mattip merged commit 1cb3871 into numpy:master Mar 26, 2020
@mattip
Copy link
Member

mattip commented Mar 26, 2020

Thanks @pdebuyl

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

Labels

00 - Bug 04 - Documentation component: documentation triaged Issue/PR that was discussed in a triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants