On Mon, Jul 13, 2009 at 10:10 AM, Ryan Krauss<ryanli...@gmail.com> wrote: > Sorry, this is a duplicate post if you follow the disussions on the google > codesite for this issue. I wanted to get as much input as possible. > Following a suggestion from Ondrej, I am replacing 'inline' = True or False > with 'mode' = 'inline', 'plain', 'equation' or 'equation*' for sympy.latex. > I need the 'plain' output for my report generation work. 'plain' means > don't wrap the latex in anything (neither '$...$' nor '\begin{equation*} .. > \end{equation*}'). > > I have this implemented. It is on my github repo > git://github.com/ryanGT/sympy.git > in the branch latex_mode.
I can see this patch in there: diff --git a/sympy/printing/latex.py b/sympy/printing/latex.py index 2c28e67..17f103e 100644 --- a/sympy/printing/latex.py +++ b/sympy/printing/latex.py @@ -41,7 +41,9 @@ class LatexPrinter(Printer): def doprint(self, expr): tex = Printer.doprint(self, expr) - if self._settings['inline']: + if self._settings['inline'] is None: + return tex + elif self._settings['inline']: return r"$%s$" % tex else: return r"\begin{equation*}%s\end{equation*}" % tex and tests: + assert latex(expr) == '$x + y$' + assert latex(expr, inline=None) == 'x + y' + assert latex(expr, inline=False)== '\\begin{equation*}x + y\\end{equation*}' > > I changed the docstring and doctest and I think they pass (not entirely sure > how to run doctests, but bin/doctest -v sympy/printing/latex.py seems to > pass 1 test). There is also a deprecation message for inline as a karg, and > I think I handle inline=True and inline=False correctly ('mode'='inline' or > 'mode'='equation*'). > > Ondrej suggested that the default for 'mode' be set to 'plain'. What are > the thoughts of the list? Right now the default for inline is True, which > would correspond to 'mode' = 'inline'. I don't really care either way. > Right now, I have the default set to 'plain', which breaks all the tests in > printing/test_latex.py. What is the best approach to fixing the tests? I > think there are 3 options and I don't care which we choose: > > 1. change the default 'mode' to 'inline' (this is the easiest) > 2. remove the '$' from the expected test outputs (right hand sides of the > assertions) to make them the expected plain output > 3. create an inline_kargs dict and pass it to all the tests (left hand sides > of the assertions) > > Do those 3 options make sense? Any thoughts on which is best? We need to test all options thoroughly anyways. So I would change the left hand side of the tests to match the right hand side, e.g. whatever mode=".." is needed. This is the old functionality, just refactored. And then I would add new tests for the new functionality, e.g. mode="plain". As to the default mode, I think it should be without "$". Sage does that too and I think it's generally better. But what is the default can be trivially changed anytime later, so that's not a big deal to get solved now. Ondrej --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---