-
-
Notifications
You must be signed in to change notification settings - Fork 556
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
Remove backslash hack in doctest #39186
Remove backslash hack in doctest #39186
Conversation
Documentation preview for this PR (built with commit 0ed925b; changes) is ready! 🎉 |
There's a little issue e.g. with the
This modifies the code however. Is it a problem (factually incorrect)? Then there are other cases where the file is autogenerated… (I don't know where the source is)
Helper script: from pathlib import Path
import re
backslash_replacer = re.compile(r"^( *)sage:(.*)\\\ *\n((?:\ *\.\.\.\.\:.*\\\ *\n)*)(\ *)(.*)", flags=re.MULTILINE)
def do_replace(string):
m = backslash_replacer.search(string)
while m is not None:
g = m.groups()
if g[4].startswith(("sage:", "....:")):
m = backslash_replacer.search(string, m.start()+1)
else:
string = (string[:m.start()] + g[0] + "sage:" + g[1] + "\\\n" + g[2] +
g[0] + "....: " +
" " * max(0, len(g[3])-len(g[0])-6) +
g[4] + string[m.end():])
m = backslash_replacer.search(string) # may have exponential complexity
return string
for f in """
src/doc/en/developer/coding_basics.rst
src/doc/en/thematic_tutorials/lie/crystals.rst
src/doc/en/thematic_tutorials/lie/branching_rules.rst
src/doc/en/thematic_tutorials/sandpile.rst
src/sage/coding/delsarte_bounds.py
src/sage/coding/extended_code.py
src/sage/coding/information_set_decoder.py
src/sage/coding/linear_code.py
src/sage/coding/linear_code_no_metric.py
src/sage/combinat/designs/gen_quadrangles_with_spread.pyx
src/sage/doctest/parsing.py
src/sage/dynamics/arithmetic_dynamics/affine_ds.py
src/sage/dynamics/arithmetic_dynamics/wehlerK3.py
src/sage/doctest/forker.py
src/sage/features/__init__.py
src/sage/dynamics/arithmetic_dynamics/projective_ds.py
src/sage/geometry/polyhedron/base4.py
src/sage/graphs/graph.py
src/sage/groups/conjugacy_classes.py
src/sage/groups/group.pyx
src/sage/interfaces/qepcad.py
src/sage/knots/knotinfo.py
src/sage/libs/ntl/ntl_mat_GF2.pyx
src/sage/manifolds/differentiable/affine_connection.py
src/sage/matrix/matrix_polynomial_dense.pyx
src/sage/numerical/backends/interactivelp_backend.pyx
src/sage/numerical/backends/glpk_backend.pyx
src/sage/rings/multi_power_series_ring.py
src/sage/rings/multi_power_series_ring_element.py
src/sage/rings/polynomial/multi_polynomial.pyx
src/sage/rings/polynomial/multi_polynomial_ideal.py
src/sage/rings/polynomial/pbori/gbcore.py
src/sage/schemes/jacobians/abstract_jacobian.py
src/sage/schemes/product_projective/rational_point.py
src/sage/schemes/product_projective/subscheme.py
src/sage/schemes/projective/projective_space.py
src/sage/symbolic/expression.pyx
src/sage/tensor/modules/tensor_with_indices.py
src/sage/tests/book_stein_ent.py
src/sage/tests/books/computational-mathematics-with-sagemath/float_doctest.py
src/sage/tests/books/computational-mathematics-with-sagemath/integration_doctest.py
src/sage/topology/simplicial_complex.py
""".strip().splitlines():
f = Path("~/sage").expanduser()/f
if f.is_file() and f.suffix not in (".pyc",):
string = f.read_text(errors="ignore")
string1 = do_replace(string)
if string1 != string:
#print(string)
f.write_text(string1)
print("Changed:", f)
else: print("No changes:", f)
else: assert False |
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.
+1 on using standard python syntax for this
sagemathgh-39186: Remove backslash hack in doctest Would fix sagemath#39058 . I think it's cleaner to remove this thing anyway (given that it doesn't work in the real Sage command prompt either) ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39186 Reported by: user202729 Reviewer(s): Tobias Diez
sagemathgh-39186: Remove backslash hack in doctest Would fix sagemath#39058 . I think it's cleaner to remove this thing anyway (given that it doesn't work in the real Sage command prompt either) ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39186 Reported by: user202729 Reviewer(s): Tobias Diez
sagemathgh-39186: Remove backslash hack in doctest Would fix sagemath#39058 . I think it's cleaner to remove this thing anyway (given that it doesn't work in the real Sage command prompt either) ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39186 Reported by: user202729 Reviewer(s): Tobias Diez
sagemathgh-39186: Remove backslash hack in doctest Would fix sagemath#39058 . I think it's cleaner to remove this thing anyway (given that it doesn't work in the real Sage command prompt either) ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39186 Reported by: user202729 Reviewer(s): Tobias Diez
sagemathgh-39186: Remove backslash hack in doctest Would fix sagemath#39058 . I think it's cleaner to remove this thing anyway (given that it doesn't work in the real Sage command prompt either) ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39186 Reported by: user202729 Reviewer(s): Tobias Diez
sagemathgh-39186: Remove backslash hack in doctest Would fix sagemath#39058 . I think it's cleaner to remove this thing anyway (given that it doesn't work in the real Sage command prompt either) ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39186 Reported by: user202729 Reviewer(s): Tobias Diez
Would fix #39058 . I think it's cleaner to remove this thing anyway (given that it doesn't work in the real Sage command prompt either)
📝 Checklist
⌛ Dependencies