Skip to content

Commit

Permalink
sagemathgh-36034: Fix block-scoped doctest tags with \ line continu…
Browse files Browse the repository at this point in the history
…ations

    
<!-- ^^^^^
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 sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
Fixes
sagemath#36033 (comment)
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#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.
- [ ] 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
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->
- Depends on sagemath#36025 (merged here)

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36034
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee, Matthias Köppe
  • Loading branch information
Release Manager committed Aug 12, 2023
2 parents e8453e1 + 669065a commit 5340692
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/sage/coding/code_constructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,7 @@ def ToricCode(P,F):
sage: C.minimum_distance()
24
sage: C.minimum_distance(algorithm="guava") # optional - gap_package_guava
...
24
...24
sage: C = codes.ToricCode([[-2,-2],[-1,-2],[-1,-1],[-1,0],
....: [0,-1],[0,0],[0,1],[1,-1],[1,0]], GF(5))
sage: C
Expand Down
6 changes: 2 additions & 4 deletions src/sage/coding/linear_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,8 +911,7 @@ def covering_radius(self):
sage: C = codes.HammingCode(GF(2), 5)
sage: C.covering_radius() # optional - gap_package_guava
...
1
...1
sage: C = codes.random_linear_code(GF(263), 5, 1)
sage: C.covering_radius() # optional - gap_package_guava
Expand Down Expand Up @@ -1375,8 +1374,7 @@ def minimum_distance(self, algorithm=None):
3
sage: libgap.SetAllInfoLevels(0) # to suppress extra info messages # optional - sage.libs.gap
sage: C.minimum_distance(algorithm="guava") # optional - gap_package_guava
...
3
...3
TESTS::
Expand Down
31 changes: 24 additions & 7 deletions src/sage/doctest/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,14 +1071,36 @@ def parse(self, string, *args):
'',
(None, '5 # optional guava\n', 'Integer(5) # optional guava\n'),
'']
TESTS::
sage: parse("::\n\n sage: # needs sage.combinat\n sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \\\n ....: import incidence_matrix_to_bit_rep_of_Vrep\n sage: P = polytopes.associahedron(['A',3])\n\n")
['::\n\n',
'',
(None,
'from sage.geometry.polyhedron.combinatorial_polyhedron.conversions import incidence_matrix_to_bit_rep_of_Vrep\n',
'from sage.geometry.polyhedron.combinatorial_polyhedron.conversions import incidence_matrix_to_bit_rep_of_Vrep\n'),
'',
(None,
"P = polytopes.associahedron(['A',3])\n",
"P = polytopes.associahedron(['A',Integer(3)])\n"),
'\n']
sage: example4 = '::\n\n sage: C.minimum_distance(algorithm="guava") # optional - guava\n ...\n 24\n\n'
sage: parsed4 = DTP.parse(example4)
sage: dte = parsed4[1]
sage: dte.sage_source
'C.minimum_distance(algorithm="guava") # optional - guava\n'
sage: dte.want
'...\n24\n'
"""
# Regular expressions
find_sage_prompt = re.compile(r"^(\s*)sage: ", re.M)
find_sage_continuation = re.compile(r"^(\s*)\.\.\.\.:", re.M)
find_python_continuation = re.compile(r"^(\s*)\.\.\.([^\.])", re.M)
python_prompt = re.compile(r"^(\s*)>>>", re.M)
backslash_replacer = re.compile(r"""(\s*)sage:(.*)\\\ *
\ *(((\.){4}:)|((\.){3}))?\ *""")
\ *((\.){4}:)?\ *""")

# The following are used to allow ... at the beginning of output
ellipsis_tag = "<TEMP_ELLIPSIS_TAG>"
Expand All @@ -1087,13 +1109,8 @@ def parse(self, string, *args):
# doctest system.
m = backslash_replacer.search(string)
while m is not None:
next_prompt = find_sage_prompt.search(string, m.end())
g = m.groups()
if next_prompt:
future = string[m.end():next_prompt.start()] + '\n' + string[next_prompt.start():]
else:
future = string[m.end():]
string = string[:m.start()] + g[0] + "sage:" + g[1] + future
string = string[:m.start()] + g[0] + "sage:" + g[1] + string[m.end():]
m = backslash_replacer.search(string, m.start())

replace_ellipsis = not python_prompt.search(string)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/dynamics/arithmetic_dynamics/wehlerK3.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def Qxa(self, a):
sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1 \
- 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - 4*x1*x2*y1^2 \
+ 5*x0*x2*y0*y2 \
- 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 \
- 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2
sage: Y = x0*y0 + x1*y1 + x2*y2
sage: X = WehlerK3Surface([Z, Y])
sage: T = PP(1, 1, 0, 1, 0, 0)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/symbolic/expression.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Check that :trac:`9880` is fixed::
11/27*b_0/((2^b_2)^2*(2^b_1)^2*(2^b_0)^2) - \
11/27*b_1/((2^b_2)^2*(2^b_1)^2*(2^b_0)^2) - \
11/27*b_2/((2^b_2)^2*(2^b_1)^2*(2^b_0)^2) + \
64/81/((2^b_2)^2*(2^b_1)^2*(2^b_0)^2) + 35/81 \
64/81/((2^b_2)^2*(2^b_1)^2*(2^b_0)^2) + 35/81
sage: f.nops()
38
Expand Down
8 changes: 4 additions & 4 deletions src/sage/tests/book_stein_ent.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
sage: factor(31415926535898)
2 * 3 * 53 * 73 * 2531 * 534697
sage: n = 7403756347956171282804679609742957314259318888\
...9231289084936232638972765034028266276891996419625117\
...8439958943305021275853701189680982867331732731089309\
...0055250511687706329907239638078671008609696253793465\
...0563796359
....: 9231289084936232638972765034028266276891996419625117\
....: 8439958943305021275853701189680982867331732731089309\
....: 0055250511687706329907239638078671008609696253793465\
....: 0563796359
sage: len(n.str(2))
704
sage: len(n.str(10))
Expand Down

0 comments on commit 5340692

Please sign in to comment.