gutow / Algebra_with_Sympy

Tools for doing stepwise algebra in an on paper like manner using SymPy.
https://gutow.github.io/Algebra_with_Sympy/
GNU General Public License v3.0
17 stars 3 forks source link

Implement rewrite(Add) #8

Closed Davide-sd closed 2 years ago

Davide-sd commented 2 years ago

Hello gutow, this is a very nice package.

Would it be possible to implement the rewrite method so that when a user execute eq.rewrite(Add) it returns eq.lhs - eq.rhs, like SymPy's Eq does?

gutow commented 2 years ago

If you are using this to input into solve, the experimental override of solve in the package already does this. Try something like this:

var('a b c')
eq1 =@ a - b = c/a
solve(eq1,a)

This should return both the typeset and python code versions of the solutions.

Is there a more general reason the rewrite would be needed?

gutow commented 2 years ago

Hello gutow, this is a very nice package.

Thank you.

gutow commented 2 years ago

@Davide-sd should this issue remain open? Is there another use for rewrite other then making input for solve?

Davide-sd commented 2 years ago

Please leave it open for a few more days, as I'm still trying this module and I have to fully understand if this feature might be useful or what...

Davide-sd commented 2 years ago

@gutow : how do you usually run tests on your local machine? I naively run the pytest command from the root folder, but I got the following error:

_________________ERROR collecting tests/test_algebraic_equation.py _________________________________________
tests/test_algebraic_equation.py:55: in <module>
    exec(execstr, globals(), locals())
<string>:1: in <module>
    ???
E   TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
gutow commented 2 years ago

@gutow : how do you usually run tests on your local machine? I naively run the pytest command from the root folder, but I got the following error:

_________________ERROR collecting tests/test_algebraic_equation.py _________________________________________
tests/test_algebraic_equation.py:55: in <module>
    exec(execstr, globals(), locals())
<string>:1: in <module>
    ???
E   TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

Davide, Sorry about that. In my rush to get out the fix to be compatible with sympy 1.11 (added a function that isn't part of function class), I did not update the way tests load and override the sympy functions.

I am working on a more robust way of doing this that should not require updating tests when sympy adds other non-compliant functions.

If you need to run tests you can fix this by adding the string 'piecewise_exclusive' to skip list that begins on line 49 of test_algebraic_equation.py.