So, when would just adding an args.reverse() breakdown:

den3 = s**4*m1*m2+k*s**2*m2+Gc*k
args = list(den3.args)
args.sort(sympy.Basic._compare_pretty)
args.reverse()

seems to produce the ordering that I want.  Adding the reverse line to
str.py and latex.py _print_Add methods seems to work.  But obviously this is
a hack.


On Mon, Jun 1, 2009 at 3:54 PM, Ryan Krauss <ryanli...@gmail.com> wrote:

> That sounds good, but what do you mean by
> "write a sympy code that orders the list of arguments of the Add instance
> above, which it is easy -- you just order it with respect to 's'"
>
> I understand that that is what I want to do, but how do I get started
> coding it up?
>
>
> On Mon, Jun 1, 2009 at 3:29 PM, Ondrej Certik <ond...@certik.cz> wrote:
>
>>
>> On Mon, Jun 1, 2009 at 2:24 PM, Ryan Krauss <ryanli...@gmail.com> wrote:
>> > I have a sympy result:
>> >
>> > In [57]: x1_res_up
>> > Out[57]: Gc*k*xd/(Gc*k + k*m1*s**2 + k*m2*s**2 + m1*m2*s**4)
>> >
>> > In [58]: type(x1_res_up)
>> > Out[58]: <class 'sympy.core.mul.Mul'>
>> >
>> > but I would like the denominator to print in decending powers of s:
>> >
>> > Gc*k*xd/(m1*m2*s**4 + k*m2*s**2 + Gc*k + k*m1*s**2)
>> >
>> > If the numerator had powers of s, I would like it to print the same way.
>> > The result is a Laplace transform and this is how my readers are used to
>> > looking at them.  Most importantly, this is the order I want them to be
>> in
>> > when they are converted to Latex.  Can this be done?  Am I missing a
>> simple
>> > keyword argument somewhere?  Maxima has an option that is something like
>> > declare('s','mainvar') or something that allows a main variable to be
>> > specified.  Is that an option?
>>
>> Currently no, but it's easy to implement, as long as you can write a
>> sympy code that orders the list of arguments of the Add instance
>> above, which it is easy -- you just order it with respect to "s". Then
>> just override the _print_Add() method, see sympy/printing/str.py, line
>> 57.
>>
>> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to