Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better compatibility with sympy ImmutableMatrix (fixes #363) #392

Merged
merged 5 commits into from
Mar 20, 2023

Conversation

rikardn
Copy link
Contributor

@rikardn rikardn commented Feb 26, 2022

  • simplify Immutable to new Immutable
  • sympy.sympify matrices to Immutable

@isuruf
Copy link
Member

isuruf commented Feb 28, 2022

Can you paste the output of the following with this PR?

import symengine
import sympy
print(type(symengine.zeros(5) + symengine.zeros(5)))
print(type(sympy.zeros(5) + sympy.zeros(5)))
print(type(symengine.zeros(5) + sympy.zeros(5)))
print(type(sympy.zeros(5) + symengine.zeros(5)))

@rikardn
Copy link
Contributor Author

rikardn commented Feb 28, 2022

Sure:

n [1]: import symengine
   ...: import sympy
   ...: print(type(symengine.zeros(5) + symengine.zeros(5)))
   ...: print(type(sympy.zeros(5) + sympy.zeros(5)))
   ...: print(type(symengine.zeros(5) + sympy.zeros(5)))
   ...: print(type(sympy.zeros(5) + symengine.zeros(5)))
<class 'symengine.lib.symengine_wrapper.MutableDenseMatrix'>
<class 'sympy.matrices.dense.MutableDenseMatrix'>
<class 'symengine.lib.symengine_wrapper.MutableDenseMatrix'>
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-61b037069457> in <module>
      4 print(type(sympy.zeros(5) + sympy.zeros(5)))
      5 print(type(symengine.zeros(5) + sympy.zeros(5)))
----> 6 print(type(sympy.zeros(5) + symengine.zeros(5)))

~/testing/myvenv/lib/python3.8/site-packages/sympy/core/decorators.py in binary_op_wrapper(self, other)
    134                     if f is not None:
    135                         return f(self)
--> 136             return func(self, other)
    137         return binary_op_wrapper
    138     return priority_decorator

~/testing/myvenv/lib/python3.8/site-packages/sympy/matrices/common.py in __add__(self, other)
   2708             # call the highest-priority class's _eval_add
   2709             a, b = self, other
-> 2710             if a.__class__ != classof(a, b):
   2711                 b, a = a, b
   2712             return a._eval_add(b)

~/testing/myvenv/lib/python3.8/site-packages/sympy/matrices/common.py in classof(A, B)
   3283             return A.__class__
   3284 
-> 3285     raise TypeError("Incompatible classes %s, %s" % (A.__class__, B.__class__))

TypeError: Incompatible classes <class 'sympy.matrices.dense.MutableDenseMatrix'>, <class 'symengine.lib.symengine_wrapper.MutableDenseMatrix'>

@isuruf isuruf added this to the 0.10.0 milestone Jun 25, 2022
rikardn and others added 4 commits March 20, 2023 16:50
simplify Immutable to new Immutable
sympy.sympify matrices to Immutable
Co-authored-by: Isuru Fernando <isuruf@gmail.com>
Co-authored-by: Isuru Fernando <isuruf@gmail.com>
@isuruf
Copy link
Member

isuruf commented Mar 20, 2023

Merging without appveyor for now as the queue is long. Will revert if appveyor fails.

Thanks for the PR @rikardn

@isuruf isuruf merged commit 6c9a264 into symengine:master Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants