# Ticket #14382: trac_14382_doctests.patch

File trac_14382_doctests.patch, 6.2 KB (added by novoselt, 8 years ago)
• ## doc/de/tutorial/latex.rst

# HG changeset patch
# User Andrey Novoseltsev <novoselt@gmail.com>
# Date 1368731554 21600
# Node ID 56a86cf42c78791efc61fa10db7e45412cbaac86
# Parent  fa7038f49d4e5dffcb7b0a07831e8b4e209d6616
Fix doctests with LaTeX code of strings.

diff --git a/doc/de/tutorial/latex.rst b/doc/de/tutorial/latex.rst
 a sage: latex(integrate(z^4, z)) \frac{1}{5} \, z^{5} sage: latex('a string') \verb|a|\phantom{\verb!x!}\verb|string| \text{\tt a{ }string} sage: latex(QQ) \Bold{Q} sage: latex(matrix(QQ, 2, 3, [[2,4,6],[-1,-1,-1]]))
• ## doc/en/tutorial/latex.rst

diff --git a/doc/en/tutorial/latex.rst b/doc/en/tutorial/latex.rst
 a sage: latex(integrate(z^4, z)) \frac{1}{5} \, z^{5} sage: latex('a string') \verb|a|\phantom{\verb!x!}\verb|string| \text{\tt a{ }string} sage: latex(QQ) \Bold{Q} sage: latex(matrix(QQ, 2, 3, [[2,4,6],[-1,-1,-1]]))
• ## sage/combinat/free_module.py

diff --git a/sage/combinat/free_module.py b/sage/combinat/free_module.py
 a sage: F = CombinatorialFreeModule(QQ, [('a', 'b'), (0,1,2)]) sage: e = F.basis() sage: latex(e[('a','b')])    # indirect doctest B_{\left(a, b\right)} B_{('a', 'b')} sage: latex(2*e[(0,1,2)])    # indirect doctest 2B_{\left(0, 1, 2\right)} sage: F = CombinatorialFreeModule(QQ, [('a', 'b'), (0,1,2)], prefix="") from sage.misc.latex import latex s = latex(m) if s.find('\\verb') != -1: import re s = re.sub("\\\\verb(.)(.*?)\\1", "\\2", s) s = s.replace("\\phantom{x}", " ") if s.find(r'\text{\tt ') != -1: # m contains "non-LaTeXed" strings, use string representation s = str(m) # dictionary with left-right pairs of "brackets".  put pairs # in here accept \\left and \\right as prefixes. sage: F.rename("F") sage: G.rename("G") sage: latex(tensor([F, F, G])) # indirect doctest \verb|F| \otimes \verb|F| \otimes \verb|G| \text{\tt F} \otimes \text{\tt F} \otimes \text{\tt G} sage: F._latex_ = lambda : "F" sage: G._latex_ = lambda : "G" sage: latex(tensor([F, F, G])) # indirect doctest
• ## sage/graphs/generic_graph.py

diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
 a "0" -- "1"; "0" -- "2"; "1" -- "2"; "2" -- "3" [label=" ", texlbl="$\verb|foo|$"]; "2" -- "3" [label=" ", texlbl="$\text{\tt foo}$"]; } Same, with a digraph and a color for edges::
• ## sage/groups/perm_gps/permgroup.py

diff --git a/sage/groups/perm_gps/permgroup.py b/sage/groups/perm_gps/permgroup.py
 a sage: S = SymmetricGroup(['a','b','c']) sage: latex(S) \langle (\verb|a|,\verb|b|,\verb|c|), (\verb|a|,\verb|b|) \rangle \langle (\text{\tt a},\text{\tt b},\text{\tt c}), (\text{\tt a},\text{\tt b}) \rangle """ return '\\langle ' + \ ', '.join([x._latex_() for x in self.gens()]) + ' \\rangle'
• ## sage/groups/perm_gps/permgroup_element.pyx

diff --git a/sage/groups/perm_gps/permgroup_element.pyx b/sage/groups/perm_gps/permgroup_element.pyx
 a sage: S = SymmetricGroup(['a', 'b']) sage: latex(S.gens()) \left[(\verb|a|,\verb|b|)\right] \left[(\text{\tt a},\text{\tt b})\right] """ from sage.misc.latex import latex return "".join(["(" + ",".join([latex(x) for x in cycle])+")" for cycle in self.cycle_tuples()])
• ## sage/misc/latex.py

diff --git a/sage/misc/latex.py b/sage/misc/latex.py
 a sage: str_function('+34.5') '+34.5' sage: str_function('hello_world') '\\verb|hello_world|' '\\text{\\tt hello{\\char\\_}world}' sage: str_function('-1.00000?') # trac 12178 '-1.00000?' """ sage: latex(FiniteField(25,'a')) \Bold{F}_{5^{2}} sage: latex("hello") \verb|hello| \text{\tt hello} sage: LatexExpr(r"\frac{x^2 - 1}{x + 1} = x - 1") \frac{x^2 - 1}{x + 1} = x - 1 sage: t = PolynomialRing(QQ, 't').0 sage: from sage.misc.latex import repr_lincomb sage: repr_lincomb(['a', 's', ''], [-t, t - 2, t^12 + 2]) '-t\\verb|a| + \\left(t - 2\\right)\\verb|s| + \\left(t^{12} + 2\\right)' '-t\\text{\\tt a} + \\left(t - 2\\right)\\text{\\tt s} + \\left(t^{12} + 2\\right)' sage: repr_lincomb(['a', 'b'], [1,1]) '\\verb|a| + \\verb|b|' '\\text{\\tt a} + \\text{\\tt b}' Verify that a certain corner case works (see :trac:5707 and :trac:5766)::
• ## sage/modular/hecke/algebra.py

diff --git a/sage/modular/hecke/algebra.py b/sage/modular/hecke/algebra.py
 a EXAMPLES:: sage: latex(CuspForms(3, 24).hecke_algebra()) # indirect doctest \mathbf{T}_{\verb|Cuspidal|...Gamma0(3)...24...} \mathbf{T}_{\text{\tt Cuspidal...Gamma0(3)...24...} """ from sage.misc.latex import latex return "\\mathbf{T}_{%s}" % latex(self.__M)
• ## sage/sets/set.py

diff --git a/sage/sets/set.py b/sage/sets/set.py`
 a :: sage: print latex(Primes()) \verb|Set...of...all...prime...numbers:...| \text{\tt Set{ }of{ }all{ }prime{ }numbers:{ }2,{ }3,{ }5,{ }7,{ }...} sage: print latex(Set([1,1,1,5,6])) \left\{1, 5, 6\right\} """