My patch to simplify a minus 1 from the numerator and denominator of a
fraction causes some failures in test_solvers because the results now have a
minus 1 factored out.  I tried changing one of the tests so that the result
would be the expected one and ran into an interesting problem.  The whole
session is below, but here is the core issue:

In [6]: res[z]
Out[6]:
-(t + n⋅t)
──────────
    n

In [7]: res[z] == -(t+n*t)/n
Out[7]: False

The problem is that the expression on the right is apparently altered as it
is executed so that
In [2]: my_res = -(t+n*t)/n

In [3]: my_res
Out[3]:
-t - n⋅t
────────
   n

This relatex to lines 153 and 154 of solvers/tests/test_solvers.py:
    assert solve_linear_system(M, x, y, z, t) == \
           {y: 0, z: -(t+t*n)/n, x: -(t+t*n)/n}

I don't know how to write the test so that sympy doesn't factor in the minus
1 in the numerator when it evalutes the assertion.

A pretty version of my session can be found here:
http://paste.blixt.org/115586

What is the right way to fix the test in test_solvers line 153?

Thanks,

Ryan

In [1]: x, y, z, t, n = symbols('xyztn')

In [2]: my_res = -(t+n*t)/n

In [3]: my_res
Out[3]:
-t - n⋅t
────────
   n

In [4]: M = Matrix([[0,0,n*(n+1),(n+1)**2,0],
   ...:                 [n+1,n+1,-2*n-1,-(n+1),0],
   ...:                 [-1, 0, 1, 0, 0]])

In [5]: res = solve_linear_system(M, x, y, z, t)

In [6]: res[z]
Out[6]:
-(t + n⋅t)
──────────
    n

In [7]: res[z] == -(t+n*t)/n
Out[7]: False

In [8]: my_res = simplify(my_res)

In [9]: my_res
Out[9]:
-(t + n⋅t)
──────────
    n

In [10]: my_res = res[z]

In [11]: my_res = -(t+n*t)/n

In [12]: my_res == res[z]
Out[12]: False

In [13]: my_res = simplify(my_res)

In [14]: my_res
Out[14]:
-(t + n⋅t)
──────────
    n

In [15]: my_res == res[z]
Out[15]: True

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to