substitute not working with SymPy
See original GitHub issueCalling sorted( )
in https://github.com/HPAC/matchpy/blob/5cae3f275e3a1f725518516bf3c700dc3be03a56/matchpy/functions.py#L87
fails with SymPy, as SymPy objects are not comparable with operators (<
, <=
, >
, >=
). Operators are overloaded in SymPy to create instances of inequality objects.
SymPy has a function called default_sort_key
meant to deal with this problem:
from sympy import symbols
x, y, z = symbols("x y z")
from sympy.core.compatibility import default_sort_key
sorted([z, x, y], key=default_sort_key)
The question is, is it possible to modify MatchPy to specify a custom sorting key so that SymPy can specify the way its objects should be sorted?
Or is it an issue with Multiset
?
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (10 by maintainers)
Top Results From Across the Web
Sympy's subs limitations - python - Stack Overflow
The first line gives the expected result (ie. a+1 ) while in the second one there is no substitution. Problem 2: factorized expressions....
Read more >subs() not working properly · Issue #12302 · sympy ... - GitHub
I tried executing the following code : In [1]: import sympy In [2]: from sympy.abc import x,y In [3]: expr1=x + x**y/x In...
Read more >SymPy - Substitution - Tutorialspoint
One of the most basic operations to be performed on a mathematical expression is substitution. The subs() function in SymPy replaces all occurrences...
Read more >Python | sympy.subs() method - GeeksforGeeks
With the help of sympy.subs() method, we can substitute all instances of a variable or expression in a mathematical expression with some other ......
Read more >Basic Operations - SymPy 1.11 documentation
Substitution replaces all instances of something in an expression with something else. ... That means that subs does not modify it in-place.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We have these tests in SymPy. I have merged some extensions to
sympy.utilities.matchpy_connector
15 days ago. We may need to wait for a new release of SymPy before we can add tests to MatchPy.Is it important to you that we create a new release of MatchPy as soon as possible? If not, I would prefer to wait a bit in case more problems show up. I guess it would also make sense to add tests for the SymPy compatibility before the next release. Are you working on those tests?