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 <[email protected]> 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 > +01 530-601-9791 > > > On Tue, Aug 26, 2014 at 6:57 PM, Alan Bromborsky <[email protected]> > 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) >> >> [image: $$ (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 [email protected]. >> To post to this group, send email to [email protected]. >> 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 [email protected]. > To post to this group, send email to [email protected]. > 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 [email protected]. > To post to this group, send email to [email protected]. > 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 [email protected]. To post to this group, send email to [email protected]. 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. For more options, visit https://groups.google.com/d/optout.
