You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gh-35749: Add style guide / reference for `# optional - sage....` doctest tags, extend `sage -t` and `sage -fixdoctests` for modularization tasks
<!-- 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. -->
- Fixing the handling of file-level `# optional` tags.
- Some files were not being doctested; fixing the recently introduced
errors in doctests.
- Implementing block-scoped tags (originally done in PR #35779, merged
here)
- Expanding the documentation on the `# optional` / `# needs` tags used
for modularization purposes, with examples.
- Adding features `sage.modular`, `sage.numerical.mip`,
`sage.rings.complex_double`, `sage.sat`
- The tools `sage -t` and `sage --fixdoctests` receive some new options
for modularization tasks (see added documentation):
```
$ make pypi-wheels
$ make SAGE_CHECK=yes sagemath-modules
$ ./sage --fixdoctests --distribution sagemath-modules \
src/sage/combinat/root_system/root_lattice_realization_algebras.py
```
(example uses #35095)
- Suppressing `# optional`/`# needs` of present features in the help
system
.
<!-- Why is this change required? What problem does it solve? -->
Motivated by the sage-devel thread https://groups.google.com/g/sage-
devel/c/utA0N1it0Eo (2023-06)
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes#12345". -->
- Resolves#35790
- Resolves#35750
- 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.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [x] 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: ...
-->
- Depends on #35820 (merged here)
- Vote at https://groups.google.com/g/sage-devel/c/8KZNRBs6F6U (result:
https://groups.google.com/g/sage-devel/c/MtS2u3VbJEo)
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
URL: #35749
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee, Matthias Köppe
parser.add_argument("-i", "--initial", action="store_true", default=False, help="only show the first failure in each file")
67
70
parser.add_argument("--exitfirst", action="store_true", default=False, help="end the test run immediately after the first failure or unexpected exception")
68
71
parser.add_argument("--force_lib", "--force-lib", action="store_true", default=False, help="do not import anything from the tested file(s)")
72
+
parser.add_argument("--if-installed", action="store_true", default=False, help="skip Python/Cython files that are not installed as modules")
69
73
parser.add_argument("--abspath", action="store_true", default=False, help="print absolute paths rather than relative paths")
70
74
parser.add_argument("--verbose", action="store_true", default=False, help="print debugging output during the test")
71
75
parser.add_argument("-d", "--debug", action="store_true", default=False, help="drop into a python debugger when an unexpected error is raised")
- If the output in your only example is very wide and cannot be reasonably
994
+
reformatted to fit (for example, large symbolic matrices or numbers with many digits),
995
+
consider showing a smaller example first.
996
+
997
+
- No need to wrap long ``import`` statements. Typically, the ``import`` statements
998
+
are not the interesting parts of the doctests. Users only need to be able to
999
+
copy-paste them into a Sage session or source file::
1000
+
1001
+
sage: from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_polydict, MPolynomialRing_polydict_domain # this is fine
1002
+
1003
+
- Wrap and indent long output to maximize readability in the source code
1004
+
and in the HTML output. But do not wrap strings::
1005
+
1006
+
sage: from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_quasi
1007
+
sage: P.<x, y, z> = ProjectiveSpace(2, ZZ)
1008
+
sage: S = P.subscheme([])
1009
+
sage: T = P.subscheme([x - y])
1010
+
sage: U = AlgebraicScheme_quasi(S, T); U
1011
+
Quasi-projective subscheme X - Y of Projective Space of dimension 2
1012
+
over Integer Ring,
1013
+
where X is defined by: (no polynomials)
1014
+
and Y is defined by: x - y
1015
+
sage: U._repr_() # this is fine
1016
+
'Quasi-projective subscheme X - Y of Projective Space of dimension 2 over Integer Ring, where X is defined by:\n (no polynomials)\nand Y is defined by:\n x - y'
1017
+
1018
+
Also, if there is no whitespace in the doctest output where you could wrap the line,
1019
+
do not add such whitespace. Just don't wrap the line::
0 commit comments