Add style guide / reference for # optional - sage.... doctest tags, extend sage -t and sage -fixdoctests for modularization tasks#35749
Conversation
…g doctests, # optional
|
(the doctest failure in ell_rational_field is unrelated) |
gh-35734: Reference manual: Show modularized sagelib packages separately <!-- Please provide a concise, informative and self-explanatory title. --> <!-- Don't put issue numbers in the title. Put it in the Description below. --> <!-- For example, instead of "Fixes #12345", use "Add a new method to multiply two integers" --> ### 📚 Description <!-- Describe your changes here in detail. --> Packages such as **sagemath-categories** are currently mixed with optional SPKGs in the reference guide. We separate them out as a separate category. We also move the section on `Feature`s right next to the package list. #35749 and follow-ups will interlink these sections. Preview: - https://deploy-preview-35734--sagemath- tobias.netlify.app/reference/spkg/index.html#packages-of-the- modularized-sage-library - https://deploy-preview-35734--sagemath- tobias.netlify.app/reference/spkg/index.html#runtime-detectable- features-and-conditional-doctests <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> - Part of #29705 <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35734 Reported by: Matthias Köppe Reviewer(s): Kwankyu Lee, Matthias Köppe
SageMath version 10.1.beta4, Release Date: 2023-06-21
…ks; add # optional on ModuleNotFoundError and 'was only set only in doctest marked' warning
|
I get $ sage --fixdoctests --help
usage: sage-fixdoctests [-h] [-l] [--distribution DISTRIBUTION] [--venv VENV] [--environment ENVIRONMENT] [--no-test] [--full-tracebacks] [--only-tags]
[--probe FEATURES] [--keep-both] [--overwrite] [--no-overwrite]
[filename ...]
Given an input file with doctests, this creates a modified file that passes the doctests (modulo any raised exceptions). By default, the input file is
modified. You can also name an output file.
positional arguments:
filename input filenames; or INPUT_FILENAME OUTPUT_FILENAME if exactly two filenames are given and neither --overwrite nor --no-overwrite is
present
options:
-h, --help show this help message and exit
-l, --long
--distribution DISTRIBUTION
distribution package to test, e.g., 'sagemath-graphs', 'sagemath-combinat[modules]'; sets defaults for --venv and --environment
--venv VENV directory name of a venv where 'sage -t' is to be run
--environment ENVIRONMENT
name of a module that provides the global environment for tests; implies --keep-both and --full-tracebacks
--no-test do not run the doctester, only rewrite '# optional/needs' tags; implies --only-tags
--full-tracebacks include full tracebacks rather than '...'
--only-tags only add '# optional/needs' tags where needed, ignore other failures
--probe FEATURES check whether '# optional - FEATURES' tags are still needed, remove these
--keep-both do not replace test results; duplicate the test instead and mark both copies # optional
--overwrite never interpret a second filename as OUTPUT; overwrite the source files
--no-overwrite never interpret a second filename as OUTPUT; output goes to files named INPUT.fixedYou may want to update the "positional arguments:" section. |
|
|
||
| sage: print_with_ruler([ | ||
| ....: update_optional_tags(' sage: unforced() # opt' 'ional - latte_int'), | ||
| ....: update_optional_tags(' sage: unforced() # opt' 'ional - latte_int', |
There was a problem hiding this comment.
Splitting the string containing # optional is still necessary? The doctester or the fixer is not robust enough yet to handle the case?
There was a problem hiding this comment.
It is tox -e relint that is not smart enough
kwankyu
left a comment
There was a problem hiding this comment.
It looks very good to me as far as I can see.
|
As this PR is motivated by the sage-devel discussion started by @tscrim, I invite him to review this PR once more. If there's no comment from him for a couple of days, I will set it positive review. |
|
Thank you! |
|
Doctests fail because now the previously-skipped broken files are picked up |
|
They all look easy to fix. All the doctests rely on arbitrary choice between |
|
We may fix them in the style --- a/src/sage/schemes/elliptic_curves/heegner.py
+++ b/src/sage/schemes/elliptic_curves/heegner.py
@@ -47,8 +47,8 @@ We find some Mordell-Weil generators in the rank 1 case using Heegner points::
sage: E = EllipticCurve('43a'); P = E.heegner_point(-7)
sage: P.x_poly_exact()
x
- sage: P.point_exact()
- (0 : 0 : 1)
+ sage: p = P.point_exact(); p == E(0,0,1) or -p == E(0,0,1)
+ True
sage: E = EllipticCurve('997a')
sage: E.rank() |
|
Please merge #35966 here for test. |
|
Documentation preview for this PR (built with commit 44549f6; changes) is ready! 🎉 |
gh-35919: `sage.matroids`: Update `# needs`, modularization fixes for imports <!-- Please provide a concise, informative and self-explanatory title. --> <!-- Don't put issue numbers in the title. Put it in the Description below. --> <!-- For example, instead of "Fixes #12345", use "Add a new method to multiply two integers" --> ### 📚 Description <!-- Describe your changes here in detail. --> - Many `# optional` are removed because small prime finite fields no longer need to be marked `# optional/needs sage.rings.finite_rings` since #35847 - Other `# optional` are replaced by codeblock-scoped `# needs` tags - Remaining `# optional` with standard features are replaced by `# needs` - Some import fixes needed for separate testing of **sagemath-modules** or **sagemath-graphs**[modules] from #35095 <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> This is: - done with the help of `sage -fixdoctests` from #35749 - Part of: #29705 - Cherry-picked from: #35095 <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35919 Reported by: Matthias Köppe Reviewer(s): David Coudert, Matthias Köppe
gh-35951: `sage.combinat.cluster_algebra_quiver`: Modularization fixes, update `# needs` <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> - `# optional` with standard features are replaced by `# needs` - Some import fixes needed for separate testing of **sagemath-graphs** from #35095 <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> This is: - done with the help of `sage -fixdoctests` from #35749 - Part of: #29705 - Cherry-picked from: #35095 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35951 Reported by: Matthias Köppe Reviewer(s): David Coudert
gh-35943: `sage.combinat.designs`: Modularization fixes, update `# needs` <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> - Many `# optional` are removed because small prime finite fields no longer need to be marked `# optional/needs sage.rings.finite_rings` since #35847 - Other `# optional` are replaced by codeblock-scoped `# needs` tags - Remaining `# optional` with standard features are replaced by `# needs` - Some import fixes needed for separate testing of **sagemath-graphs** from #35095 <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> This is: - done with the help of `sage -fixdoctests` from #35749 - Part of: #29705 - Cherry-picked from: #35095 <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35943 Reported by: Matthias Köppe Reviewer(s): David Coudert, Matthias Köppe
gh-35957: `sage.rings.function_field`: Update `# needs` <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> - Many `# optional` are removed because small prime finite fields no longer need to be marked `# optional/needs sage.rings.finite_rings` since #35847 - Other `# optional` are replaced by codeblock-scoped `# needs` tags - Remaining `# optional` with standard features are replaced by `# needs` - Some import fixes needed for separate testing of **sagemath-graphs** from #35095 <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> This is: - done with the help of `sage -fixdoctests` from #35749 - Part of: #29705 - Cherry-picked from: #35095 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35957 Reported by: Matthias Köppe Reviewer(s): David Coudert, Matthias Köppe
📚 Description
# optionaltags.# optional/# needstags used for modularization purposes, with examples.sage.modular,sage.numerical.mip,sage.rings.complex_double,sage.satsage -tandsage --fixdoctestsreceive some new options for modularization tasks (see added documentation):# optional/# needsof present features in the help system.
Motivated by the sage-devel thread https://groups.google.com/g/sage-devel/c/utA0N1it0Eo (2023-06)
# optional/# long/# needsannotation maintenance tool #35790# optionalannotations for doctests (modularization) #35750📝 Checklist
⌛ Dependencies
sage.features: Declare features as "standard" explicitly #35820 (merged here)