I looked at the TableForm class in sympy/printing/tabelform.py and have
several questions relating to _latex(self,printer).
1. In order to handle text and latex printing in a unified manner is
_sympystr(self, p) the text equivalent of _latex(self,printer).
2. I wish to have both a latex and string printer for my Dop
(differential operator) class. Currently I have custom printers
GaPrinter for
text and GaLatexPrinter for latex. Members of my Dop class is
Dop_latex_str(self) which generates the latex string for a Dop and
Dop_str(self) which generates the text string for a Dop. In the
GaLatexPrinter class I have the member
def _print_Dop(self, expr):
return expr.Dop_latex_str()
and in the GaPrinter class the member
def _print_Dop(self, expr):
return expr.Dop_str()
Should I redefine Dop_latex_str(self) as _latex(self,printer) and
Dop_str(self) as _sympystr(self, printer)?
3. If I define _latex(self,printer) and _sympystr(self, printer) do I
need _print_Dop(self, expr) in the GaLatexPrinter and GaPrinter classes?
4. Are the only members I need in the custom printer classes the ones
that are overriding the ones in the default printer classes such as
_print_Derivative(self, expr) and _print_Function(self, expr)?
On 08/26/2014 08:21 PM, Jason Moore wrote:
Yes, one way to have latex printing is to add _latex method. Then
maybe it would be worth add this line to _can_print_latex:
https://github.com/sympy/sympy/blob/master/sympy/interactive/printing.py#L105
Then anything with the _latex printing method will print.
Jason
moorepants.info <http://moorepants.info>
+01 530-601-9791
On Tue, Aug 26, 2014 at 8:20 PM, Alan Bromborsky <abro...@verizon.net
<mailto:abro...@verizon.net>> wrote:
Are you saying if my class is Dop I should have
class Dop(object):
def _latex(self,GaLatexPrinter):
etc.
where GaLatexPrinter is my custom latex printer that has member
_print_Dop.
On 08/26/2014 08:09 PM, Aaron Meurer wrote:
You can define methods on the class, depending on what printer
you want to override. For the LaTeX printer, it's _latex. The
signature should be _latex(self, printer), and it should use
printer to recursively print any subexpressions. See
http://docs.sympy.org/latest/modules/printing.html#module-sympy.printing.latex
(the printmethod attribute), and search the SymPy codebase for
some examples.
Aaron Meurer
On Tue, Aug 26, 2014 at 7:07 PM, Alan Bromborsky
<abro...@verizon.net <mailto:abro...@verizon.net>> wrote:
Can you suggest how I could override the function without
modifying interactive/printing.py?
On 08/26/2014 07:38 PM, Jason Moore wrote:
Maybe you need to override this function:
https://github.com/sympy/sympy/blob/master/sympy/interactive/printing.py#L90
Notice how some odd classes that don't fit the sympy
standards have special cases. Try adding your class to that
list and see if it works.
Jason
moorepants.info <http://moorepants.info>
+01 530-601-9791 <tel:530-601-9791>
On Tue, Aug 26, 2014 at 6:57 PM, Alan Bromborsky
<abro...@verizon.net <mailto:abro...@verizon.net>> wrote:
I am trying to print a list of instances of a custom
class. The input is -
print (o3d.grad, o3d.grad)
the output is (custom latex printer)
$$ (e_{x} \frac{\partial}{\partial x} + e_{y}
\frac{\partial}{\partial y} + e_{z}
\frac{\partial}{\partial z}, e_{x}
\frac{\partial}{\partial x} + e_{y}
\frac{\partial}{\partial y} + e_{z}
\frac{\partial}{\partial z}) $$
however in ipyrhon notebook I input
(o3d.grad, o3d.grad)
I get out
(e_{x} \frac{\partial}{\partial x} + e_{y} \frac{\partial}{\partial
y} + e_{z} \frac{\partial}{\partial z},
e_{x} \frac{\partial}{\partial x} + e_{y}
\frac{\partial}{\partial y} + e_{z} \frac{\partial}{\partial z})
Also the standard latex tuple and list printer is not
using \left ( \right and \left [ \right ) to enclose
the tuple or list. How can I write a custom latex tuple
and list printer that will also work in ipython notebook.
--
You received this message because you are subscribed to
the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails
from it, send an email to
sympy+unsubscr...@googlegroups.com
<mailto:sympy+unsubscr...@googlegroups.com>.
To post to this group, send email to
sympy@googlegroups.com <mailto:sympy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/53FD10D1.6080309%40verizon.net
<https://groups.google.com/d/msgid/sympy/53FD10D1.6080309%40verizon.net?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the
Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails
from it, send an email to sympy+unsubscr...@googlegroups.com
<mailto:sympy+unsubscr...@googlegroups.com>.
To post to this group, send email to sympy@googlegroups.com
<mailto:sympy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/CAP7f1AgriAFv0KoeL1ePt0n%3DEEjvpHYE6_2CtwoiX7%2B7%3Dp7hbg%40mail.gmail.com
<https://groups.google.com/d/msgid/sympy/CAP7f1AgriAFv0KoeL1ePt0n%3DEEjvpHYE6_2CtwoiX7%2B7%3Dp7hbg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the
Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from
it, send an email to sympy+unsubscr...@googlegroups.com
<mailto:sympy+unsubscr...@googlegroups.com>.
To post to this group, send email to sympy@googlegroups.com
<mailto:sympy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/53FD212F.6090802%40verizon.net
<https://groups.google.com/d/msgid/sympy/53FD212F.6090802%40verizon.net?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the
Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to sympy+unsubscr...@googlegroups.com
<mailto:sympy+unsubscr...@googlegroups.com>.
To post to this group, send email to sympy@googlegroups.com
<mailto:sympy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/CAKgW%3D6KkuzhJY-s5AGkjJ0DyXk6F3XC4QNkKwMNcpO66ecic0A%40mail.gmail.com
<https://groups.google.com/d/msgid/sympy/CAKgW%3D6KkuzhJY-s5AGkjJ0DyXk6F3XC4QNkKwMNcpO66ecic0A%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to sympy+unsubscr...@googlegroups.com
<mailto:sympy+unsubscr...@googlegroups.com>.
To post to this group, send email to sympy@googlegroups.com
<mailto:sympy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/53FD244E.7050900%40verizon.net
<https://groups.google.com/d/msgid/sympy/53FD244E.7050900%40verizon.net?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to sympy+unsubscr...@googlegroups.com
<mailto:sympy+unsubscr...@googlegroups.com>.
To post to this group, send email to sympy@googlegroups.com
<mailto:sympy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/CAP7f1AjYExHn0B_D6Rw_1y4cS%3DkhVf9Lkv2U8D-_4t0r8Wf%2Bdw%40mail.gmail.com
<https://groups.google.com/d/msgid/sympy/CAP7f1AjYExHn0B_D6Rw_1y4cS%3DkhVf9Lkv2U8D-_4t0r8Wf%2Bdw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/53FDD8D0.7000107%40verizon.net.
For more options, visit https://groups.google.com/d/optout.