File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -310,7 +310,7 @@ cdef extern from "<symengine/basic.h>" namespace "SymEngine":
310
310
bool is_a_Not " SymEngine::is_a<SymEngine::Not>" (const Basic & b) nogil
311
311
bool is_a_Or " SymEngine::is_a<SymEngine::Or>" (const Basic & b) nogil
312
312
bool is_a_Xor " SymEngine::is_a<SymEngine::Xor>" (const Basic & b) nogil
313
- RCP[const Basic] expand(RCP[const Basic] & o) nogil except +
313
+ RCP[const Basic] expand(RCP[const Basic] & o, bool deep ) nogil except +
314
314
void as_numer_denom(RCP[const Basic] & x, const Ptr[RCP[Basic]] & numer, const Ptr[RCP[Basic]] & denom) nogil
315
315
316
316
cdef extern from " <symengine/subs.h>" namespace " SymEngine" :
Original file line number Diff line number Diff line change @@ -844,8 +844,8 @@ cdef class Basic(object):
844
844
elif (op == 5 ):
845
845
return c2py(< RCP[const symengine.Basic]> (symengine.Ge(A.thisptr, B.thisptr)))
846
846
847
- def expand (Basic self not None ):
848
- return c2py(symengine.expand(self .thisptr))
847
+ def expand (Basic self not None , cppbool deep = True ):
848
+ return c2py(symengine.expand(self .thisptr, deep ))
849
849
850
850
def diff (Basic self not None , x = None ):
851
851
if x is None :
@@ -3560,7 +3560,7 @@ cdef class DenseMatrixBase(MatrixBase):
3560
3560
return self ._applyfunc(lambda x : x.simplify(* args, ** kwargs))
3561
3561
3562
3562
def expand (self , *args , **kwargs ):
3563
- return self .applyfunc(lambda x : x.expand())
3563
+ return self .applyfunc(lambda x : x.expand(* args, ** kwargs ))
3564
3564
3565
3565
3566
3566
def div_matrices (a , b ):
@@ -3726,8 +3726,8 @@ def diff(ex, *x):
3726
3726
ex = ex.diff(i)
3727
3727
return ex
3728
3728
3729
- def expand (x ):
3730
- return sympify(x).expand()
3729
+ def expand (x , deep = True ):
3730
+ return sympify(x).expand(deep )
3731
3731
3732
3732
expand_mul = expand
3733
3733
Original file line number Diff line number Diff line change @@ -113,9 +113,13 @@ def test_arit9():
113
113
114
114
115
115
def test_expand2 ():
116
+ x = Symbol ("x" )
116
117
y = Symbol ("y" )
117
118
z = Symbol ("z" )
118
119
assert ((1 / (y * z ) - y * z )* y * z ).expand () == 1 - (y * z )** 2
120
+ assert (2 * (x + 2 * (y + z ))).expand (deep = False ) == 2 * x + 4 * (y + z )
121
+ ex = x + 2 * (y + z )
122
+ assert ex .expand (deep = False ) == ex
119
123
120
124
121
125
def test_expand3 ():
You can’t perform that action at this time.
0 commit comments