[sympy] Re: another simplication question

2009-06-02 Thread Ondrej Certik
On Tue, Jun 2, 2009 at 12:04 PM, Ryan Krauss wrote: > I was thinking the same thing about making it work for all printers. > > I will read the patch howto tomorrow and hopefully submit shortly after > that Ok, excellent. If you need any help with git, just ask. Ondrej --~--~-~--~-

[sympy] Re: another simplication question

2009-06-02 Thread Ryan Krauss
I was thinking the same thing about making it work for all printers. I will read the patch howto tomorrow and hopefully submit shortly after that On Tue, Jun 2, 2009 at 12:30 PM, Ondrej Certik wrote: > On Tue, Jun 2, 2009 at 8:25 AM, Ryan Krauss wrote: > > OK, there is probably a cleaner w

[sympy] Re: another simplication question

2009-06-02 Thread Ondrej Certik
On Tue, Jun 2, 2009 at 8:25 AM, Ryan Krauss wrote: > OK, there is probably a cleaner way to implement this, but the following > seems to be working: > >     def _print_Add(self, expr): >     args = list(expr.args) >     if self._mainvar is not None: >     mainvar = self._mainvar >

[sympy] Re: another simplication question

2009-06-02 Thread Ryan Krauss
OK, there is probably a cleaner way to implement this, but the following seems to be working: def _print_Add(self, expr): args = list(expr.args) if self._mainvar is not None: mainvar = self._mainvar def compare_exponents(a, b): p1, p2, p3

[sympy] Re: another simplication question

2009-06-02 Thread Ryan Krauss
OK, I further hacked up compare_exponents and think I have a solution: def compare_exponents(a, b): print('') print('a = %s' % a) print('b = %s' % b) print('mainvar = %s' % mainvar) p1, p2, p3 =

[sympy] Re: another simplication question

2009-06-02 Thread Ryan Krauss
I have an approach. It is fairly rough and not completely working: In printing/latex.py def latex(expr, inline=True, matstr=None, matdelim=None, \ mainvar=None, descending=False): if inline: if matstr is None: matstr = 'smallmatrix' if matdelim is None:

[sympy] Re: another simplication question

2009-06-02 Thread Ryan Krauss
Thanks. I think I understand what this code does. How do you want it patched? Am I just writing my own alternative to sympy.latex? Are mainvar and descending keyword arguments to sympy.latex or some other printing function? I assume not everyone wants their polynomials in order of descending p

[sympy] Re: another simplication question

2009-06-01 Thread Ondrej Certik
On Mon, Jun 1, 2009 at 9:33 PM, Ryan Krauss wrote: > So, I think I have a good test and a better understanding of the problem: > > mylist = ['m', 's', 'b', 'x', 'y', 's', 'x', 'y', 's', 'EI'] > sympy.var(mylist) > test = m*s**2+b*x*y*s+x**2+y**2+s+EI > args = list(test.args) > args.sort(sympy.Bas

[sympy] Re: another simplication question

2009-06-01 Thread Ryan Krauss
So, I think I have a good test and a better understanding of the problem: mylist = ['m', 's', 'b', 'x', 'y', 's', 'x', 'y', 's', 'EI'] sympy.var(mylist) test = m*s**2+b*x*y*s+x**2+y**2+s+EI args = list(test.args) args.sort(sympy.Basic._compare_pretty) args.reverse() This doesn't get my list in t

[sympy] Re: another simplication question

2009-06-01 Thread Ondrej Certik
On Mon, Jun 1, 2009 at 3:39 PM, Ryan Krauss wrote: > 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 l

[sympy] Re: another simplication question

2009-06-01 Thread Ryan Krauss
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 o

[sympy] Re: another simplication question

2009-06-01 Thread Ryan Krauss
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,

[sympy] Re: another simplication question

2009-06-01 Thread Ondrej Certik
On Mon, Jun 1, 2009 at 2:24 PM, Ryan Krauss 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]: > > but I would like the denominator to print in decending powers of s: > > Gc*k*xd/(m1*m2*s**