We should add an option to the printers to do this. I think some of
the printers (particularly the code printers) ought to do this by
default.

Aaron Meurer

On Thu, Jul 14, 2016 at 6:39 PM, Aaron Meurer <[email protected]> wrote:
> I looked at it too and I don't think it supports a callable, but it would be
> nice if it did.
>
> Aaron Meurer
>
> On Thu, Jul 14, 2016 at 2:07 PM, Björn Dahlgren <[email protected]> wrote:
>>
>>
>>
>> On Thursday, 14 July 2016 11:07:28 UTC+2, Björn Dahlgren wrote:
>>>
>>> For reference (if anyone googles this):
>>>
>>> >>> latex((y-x)*(z-y), order='old')
>>> '\\left(y - x\\right) \\left(z - y\\right)'
>>>
>>
>> That didn't work:
>>
>> >>> print(latex(f(x) - 1, order='old'))
>> -1 + f{\left (x \right )}
>>
>>
>>
>>  here's my next iteration
>>
>> >>> from sympy.core.function import _coeff_isneg
>> >>> from sympy.printing.latex import LatexPrinter
>> >>> class MyLatexPrinter(LatexPrinter):
>> ...    def _as_ordered_terms(self, expr, order=None):
>> ...        return sorted(Add.make_args(expr), key=lambda arg:
>> (_coeff_isneg(arg),) + arg.sort_key())
>> ...
>> >>> print(MyLatexPrinter().doprint(f(x) - 1))
>> f{\left (x \right )} - 1
>>
>>
>> Unfortunately this relies by importing a non-public function
>> "_coeff_isneg", so no guarantee that it will keep working. I looked into the
>> kwarg "order" used by the printers, but I didn't quite manage to figure out
>> how to pass e.g. a callable which would let non-negativity take precedence
>> over lexiographical order.
>>
>> --
>> 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 https://groups.google.com/group/sympy.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sympy/a1a9f471-b4a9-47ba-ba71-32f6fdc63ce4%40googlegroups.com.
>>
>> 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 https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6JF6T_pbZFwAVteFRcO-eJ-oEuoDbPTGGCoasASqDPaGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to