-
Notifications
You must be signed in to change notification settings - Fork 108
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
Run doctest and fix old examples #865
Conversation
e092f52
to
28c3f72
Compare
c0cdf8e
to
f7e3a38
Compare
f7e3a38
to
dfea0ce
Compare
dfea0ce
to
bf45cf1
Compare
if [[ $INSTALL_NUMBA == "1" ]]; then micromamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" "numba>=0.57"; fi | ||
if [[ $INSTALL_JAX == "1" ]]; then micromamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" jax jaxlib numpyro && pip install tensorflow-probability; fi | ||
if [[ $INSTALL_TORCH == "1" ]]; then micromamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" pytorch pytorch-cuda=12.1 -c pytorch -c nvidia; fi | ||
|
||
pip install pytest-sphinx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only available via pip
bf45cf1
to
1634a2f
Compare
Doctests are working on the remote CI! I couldn't find a way to trigger doctest locally automatically by playing with I tried several flavors of: [tool.pytest]
addopts = [
"--durations=50",
"--doctest-modules pytensor --ignore=pytensor/misc/check_duplicate_key.py --ignore=pytensor/link",
]
testpaths = [
"pytensor", # for doctests
"tests/",
] And then tested by seeing if this would return anything: So I've been using the explicit command (same that is in the CI) to run locally, which works |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #865 +/- ##
==========================================
+ Coverage 80.99% 81.13% +0.14%
==========================================
Files 169 169
Lines 46939 46961 +22
Branches 11467 11478 +11
==========================================
+ Hits 38019 38103 +84
+ Misses 6713 6642 -71
- Partials 2207 2216 +9
|
Ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the pytest-sphinx readme and initially I wasn't able to see any extra feature with respect to pytest. It does seem that with either of them using a specific path for test files and --doctest-modules
at the same time does not work.
I have tried locally to run
pytest --doctest-modules --ignore=pytensor/misc/check_duplicate_key.py pytensor --ignore=pytensor/link --benchmark-skip
and got 30 tests to run. The found 31 because pytensor/sparse/basic.py::pytensor.sparse.basic.block_diag uses the testcode directive, which means pytest-sphinx is needed to parse that as a test. Everywhere else direct doctest syntax is used so pytest alone recognizes the other 30 tests without pytest-sphinx.
It might be better to modify the test in sparse/basic to use doctest syntax and not add the extra dependency
In #858 I used pytest-sphinx as well, I like it more than the doctest approach? Is there a strong preference for not adding it as an extra-dependency on your side @OriolAbril? |
No, just trying to keep things simple given doctest directive is nearly equivalent to testcode+testoutput, the only difference being block vs line execution, but if using directives to separate test code and output helps then use the extension |
Description
Spinoff from #858
Related Issue
Checklist
Type of change