Skip to content
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

Add --doctest-ufunc option to doctest Numpy ufuncs #174

Merged
merged 4 commits into from
Feb 10, 2022

Conversation

lpsinger
Copy link
Contributor

@lpsinger lpsinger commented Feb 5, 2022

This absorbs the functionality of the pytest-doctest-ufunc package, which was heavily based on pytest-doctestplus to begin with.

pytest-doctest-ufunc will be retired.

Fixes #123.

@lpsinger lpsinger force-pushed the doctest-ufunc branch 4 times, most recently from 1a58f92 to d2bb21a Compare February 6, 2022 00:00
Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

This looks very nice to me! Main question is about making numpy a requirement.

setup.cfg Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
tests/test_doctest_ufunc.py Outdated Show resolved Hide resolved
};


PyMODINIT_FUNC PyInit__module2(void); /* Silence -Wmissing-prototypes */
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by 'still'? To the best of my knowledge, this is always necessary to suppress the warning in C if you are declaring a non-static function.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's just that I haven't had to do this double declaration (e.g., in pyerfa), and I cannot see any difference in the imports you make...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It may not be necessary if you don't have warnings cranked all the way up. I'll try without.

@lpsinger
Copy link
Contributor Author

lpsinger commented Feb 7, 2022

The tests are failing due to a warning because I use testdir.copy_example, which was formally added in pytest 6.2. pytest-doctestplus currently requires pytest >= 4.6. Should I port my test so that it works without warnings on pytest 4.6? Or is it OK to bump the required version of pytest to 6.2?

@bsipocz
Copy link
Member

bsipocz commented Feb 7, 2022

pytest 6.2 came out in 2020 Dec, so it's a bit borderlines, but I think it's OK to require it. I'm OTOH would not add numpy as a required dependency, only as an optional.

@pllim
Copy link
Contributor

pllim commented Feb 7, 2022

I am about to bump pytest all the way to 7 at astropy/astropy#12823 😬

.gitignore Outdated Show resolved Hide resolved
@bsipocz
Copy link
Member

bsipocz commented Feb 7, 2022

I am about to bump pytest all the way to 7 at

doctestplus supports much more than astropy core, so if possible I would like to be a bit more conservative here.

This absorbs the functionality of the pytest-doctest-ufunc package,
which was heavily based on pytest-doctestplus to begin with.

pytest-doctest-ufunc will be retired.

Fixes scientific-python#123.
@lpsinger lpsinger force-pushed the doctest-ufunc branch 2 times, most recently from ced3099 to 151ef0b Compare February 7, 2022 18:45
@lpsinger
Copy link
Contributor Author

lpsinger commented Feb 7, 2022

doctestplus supports much more than astropy core, so if possible I would like to be a bit more conservative here.

OK, fixed now.

@saimn
Copy link
Contributor

saimn commented Feb 7, 2022

Can we just do that by default, without needing a new option ? Is there a downside ?

@lpsinger
Copy link
Contributor Author

lpsinger commented Feb 7, 2022

Can we just do that by default, without needing a new option ? Is there a downside ?

Do what by default?

@mhvk
Copy link
Contributor

mhvk commented Feb 7, 2022

I think @saimn meant whether we can just check the ufunc docstrings by default rather than have a separate option to turn that part on/off. I guess that makes sense - we're really just ensuring here that docstrings that one would naively expect to be checked are in fact checked.

@lpsinger
Copy link
Contributor Author

lpsinger commented Feb 7, 2022

I think @saimn meant whether we can just check the ufunc docstrings by default rather than have a separate option to turn that part on/off. I guess that makes sense - we're really just ensuring here that docstrings that one would naively expect to be checked are in fact checked.

I'm fine either way. Just say the word.

@mhvk
Copy link
Contributor

mhvk commented Feb 7, 2022

Hmm, since there doesn't seem a downside, I'd say let's make this automatic!

@saimn
Copy link
Contributor

saimn commented Feb 7, 2022

yes, that's what I meant. I guess the only downside would be the small overhead to check if each function is a ufunc but that should be negligible ?

@lpsinger
Copy link
Contributor Author

lpsinger commented Feb 7, 2022

yes, that's what I meant. I guess the only downside would be the small overhead to check if each function is a ufunc but that should be negligible ?

The downside is that someone may have exotic code that messes with and wraps functions in a way that is similar to but incompatible with Numpy, and that triggers the code path to search for docstrings in ufuncs, which for one reason or another happens not to work.

@lpsinger
Copy link
Contributor Author

lpsinger commented Feb 7, 2022

Hmm, since there doesn't seem a downside, I'd say let's make this automatic!

Done.

CHANGES.rst Outdated Show resolved Hide resolved
@pllim
Copy link
Contributor

pllim commented Feb 8, 2022

Have you tried running the astropy test suite using this branch?

p.s. Given pytest 7 and scipy 1.8 introduced a whole bunch of warnings, you might want to wait for astropy/astropy#12823 or make sure you don't use the latest releases from pytest nor scipy.

Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>
Copy link
Contributor

@saimn saimn left a comment

Choose a reason for hiding this comment

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

Ok, let's merge this and we will run the astropy test suite with the dev version before making a new release. Thanks @lpsinger.

@saimn saimn merged commit c7b22b1 into scientific-python:main Feb 10, 2022
@lpsinger lpsinger deleted the doctest-ufunc branch February 10, 2022 18:39
@lpsinger
Copy link
Contributor Author

Thank you!

@pllim
Copy link
Contributor

pllim commented Feb 14, 2022

I am going to try this out at astropy/astropy#12853 . Thanks!

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

Successfully merging this pull request may close these issues.

Take over pytest-doctest-ufunc?
5 participants