@@ -31,11 +31,11 @@ class SympifyError(Exception):
31
31
cdef c2py(RCP[const symengine.Basic] o):
32
32
cdef Basic r
33
33
if (symengine.is_a_Add(deref(o))):
34
- r = Basic .__new__ (Add)
34
+ r = Expr .__new__ (Add)
35
35
elif (symengine.is_a_Mul(deref(o))):
36
- r = Basic .__new__ (Mul)
36
+ r = Expr .__new__ (Mul)
37
37
elif (symengine.is_a_Pow(deref(o))):
38
- r = Basic .__new__ (Pow)
38
+ r = Expr .__new__ (Pow)
39
39
elif (symengine.is_a_Integer(deref(o))):
40
40
if (deref(symengine.rcp_static_cast_Integer(o)).is_zero()):
41
41
return S.Zero
@@ -59,7 +59,7 @@ cdef c2py(RCP[const symengine.Basic] o):
59
59
elif (symengine.is_a_Symbol(deref(o))):
60
60
if (symengine.is_a_PySymbol(deref(o))):
61
61
return < object > (deref(symengine.rcp_static_cast_PySymbol(o)).get_py_object())
62
- r = Basic .__new__ (Symbol)
62
+ r = Expr .__new__ (Symbol)
63
63
elif (symengine.is_a_Constant(deref(o))):
64
64
r = S.Pi
65
65
if (symengine.eq(deref(o), deref(r.thisptr))):
@@ -110,9 +110,9 @@ cdef c2py(RCP[const symengine.Basic] o):
110
110
elif (symengine.is_a_Gamma(deref(o))):
111
111
r = Function.__new__ (Gamma)
112
112
elif (symengine.is_a_Derivative(deref(o))):
113
- r = Basic .__new__ (Derivative)
113
+ r = Expr .__new__ (Derivative)
114
114
elif (symengine.is_a_Subs(deref(o))):
115
- r = Basic .__new__ (Subs)
115
+ r = Expr .__new__ (Subs)
116
116
elif (symengine.is_a_RealDouble(deref(o))):
117
117
r = Number.__new__ (RealDouble)
118
118
elif (symengine.is_a_ComplexDouble(deref(o))):
@@ -208,7 +208,7 @@ cdef c2py(RCP[const symengine.Basic] o):
208
208
elif (symengine.is_a_PyNumber(deref(o))):
209
209
r = PyNumber.__new__ (PyNumber)
210
210
elif (symengine.is_a_Piecewise(deref(o))):
211
- r = Basic .__new__ (Piecewise)
211
+ r = Function .__new__ (Piecewise)
212
212
elif (symengine.is_a_Contains(deref(o))):
213
213
r = Boolean.__new__ (Contains)
214
214
elif (symengine.is_a_Interval(deref(o))):
@@ -1078,7 +1078,11 @@ def series(ex, x=None, x0=0, n=6, as_deg_coef_pair=False):
1078
1078
return add(* l)
1079
1079
1080
1080
1081
- class Symbol (Basic ):
1081
+ cdef class Expr(Basic):
1082
+ pass
1083
+
1084
+
1085
+ class Symbol (Expr ):
1082
1086
1083
1087
"""
1084
1088
Symbol is a class to store a symbolic variable with a given name.
@@ -1166,7 +1170,7 @@ def symarray(prefix, shape, **kwargs):
1166
1170
return arr
1167
1171
1168
1172
1169
- cdef class Constant(Basic ):
1173
+ cdef class Constant(Expr ):
1170
1174
1171
1175
def __cinit__ (self , name = None ):
1172
1176
if name is None :
@@ -1268,7 +1272,7 @@ cdef class EulerGamma(Constant):
1268
1272
eulergamma = EulerGamma()
1269
1273
1270
1274
1271
- cdef class Boolean(Basic ):
1275
+ cdef class Boolean(Expr ):
1272
1276
1273
1277
def logical_not (self ):
1274
1278
return c2py(< RCP[const symengine.Basic]> (deref(symengine.rcp_static_cast_Boolean(self .thisptr)).logical_not()))
@@ -1452,7 +1456,7 @@ class StrictLessThan(Relational):
1452
1456
Lt = StrictLessThan
1453
1457
1454
1458
1455
- cdef class Number(Basic ):
1459
+ cdef class Number(Expr ):
1456
1460
@property
1457
1461
def is_Atom (self ):
1458
1462
return True
@@ -1583,7 +1587,6 @@ class Integer(Rational):
1583
1587
def is_integer (self ):
1584
1588
return True
1585
1589
1586
- @property
1587
1590
def doit (self , **hints ):
1588
1591
return self
1589
1592
@@ -1970,7 +1973,7 @@ class Half(Rational):
1970
1973
half = Half()
1971
1974
1972
1975
1973
- class AssocOp (Basic ):
1976
+ class AssocOp (Expr ):
1974
1977
1975
1978
@classmethod
1976
1979
def make_args (cls , expr ):
@@ -2086,7 +2089,7 @@ class Mul(AssocOp):
2086
2089
return d
2087
2090
2088
2091
2089
- class Pow (Basic ):
2092
+ class Pow (Expr ):
2090
2093
2091
2094
def __new__ (cls , a , b ):
2092
2095
return _sympify(a) ** b
@@ -2108,6 +2111,10 @@ class Pow(Basic):
2108
2111
def is_Pow (self ):
2109
2112
return True
2110
2113
2114
+ @property
2115
+ def is_commutative (self ):
2116
+ return (self .base.is_commutative and self .exp.is_commutative)
2117
+
2111
2118
def _sympy_ (Basic self ):
2112
2119
cdef RCP[const symengine.Pow] X = symengine.rcp_static_cast_Pow(self .thisptr)
2113
2120
base = c2py(deref(X).get_base())
@@ -2125,7 +2132,7 @@ class Pow(Basic):
2125
2132
return self .__class__
2126
2133
2127
2134
2128
- class Function (Basic ):
2135
+ class Function (Expr ):
2129
2136
2130
2137
def __new__ (cls , *args , **kwargs ):
2131
2138
if cls == Function and len (args) == 1 :
@@ -2694,7 +2701,7 @@ class Min(Function):
2694
2701
return self .__class__
2695
2702
2696
2703
2697
- class Derivative (Basic ):
2704
+ class Derivative (Expr ):
2698
2705
2699
2706
def __new__ (self , expr , *variables ):
2700
2707
if len (variables) == 1 and is_sequence(variables[0 ]):
@@ -2740,7 +2747,7 @@ class Derivative(Basic):
2740
2747
return self .__class__
2741
2748
2742
2749
2743
- class Subs (Basic ):
2750
+ class Subs (Expr ):
2744
2751
2745
2752
def __new__ (self , expr , variables , point ):
2746
2753
return sympify(expr).subs(variables, point)
@@ -2791,7 +2798,7 @@ class Subs(Basic):
2791
2798
return self .__class__
2792
2799
2793
2800
2794
- class Piecewise (Basic ):
2801
+ class Piecewise (Function ):
2795
2802
2796
2803
def __new__ (self , *args ):
2797
2804
return piecewise(* args)
@@ -2805,7 +2812,7 @@ class Piecewise(Basic):
2805
2812
return sympy.Piecewise(* l)
2806
2813
2807
2814
2808
- cdef class Set(Basic ):
2815
+ cdef class Set(Expr ):
2809
2816
2810
2817
def intersection (self , a ):
2811
2818
cdef Set other = sympify(a)
0 commit comments