Is your class subclassing from Basic (or Expr)? If not, it won't be inheriting the __str__ method that automatically uses sstr().
Aaron Meurer On Sun, Sep 25, 2022 at 11:00 AM brombo <[email protected]> wrote: > > In my class I have _latex and _sympystr. Your latex() function uses my > _latex but str() does not use _sympystr I have to define __str__() in my > class to print correctly. How should I use _sympystr to return the correct > string. > > def _sympystr(self,printer): > if self.order == 0: > return 'D{}' > s = 'D' > for x in self.pdiffs: > s += '{' + printer._print(x) + '}' > n = self.pdiffs[x] > if n > 1: > s += '^' + printer._print(n) > return s > > def _latex(self,printer): > if self.order == 0: > return '' > s = r'\frac{\partial' > if self.order > 1: > s += '^{' + printer._print(self.order) + '}' > s += '}{' > keys = list(self.pdiffs.keys()) > keys.sort(key=lambda x: x.sort_key()) > for key in keys: > i = self.pdiffs[key] > s += r'\partial ' + printer._print(key) > if i > 1: > s += '^{' + printer._print(i) + '}' > s += '}' > return s > > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/3681a732-62ca-4169-84ea-291b92dccef4n%40googlegroups.com. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2BgZtT8%3D%2BKBgiAOZ%3DhG-ae9mfah%2BkCQtUoX_Yain0RTTQ%40mail.gmail.com.
