@@ -278,10 +278,10 @@ def sympy2symengine(a, raise_error=False):
278278 """
279279 import sympy
280280 from sympy.core.function import AppliedUndef as sympy_AppliedUndef
281- if isinstance (a, sympy.Symbol):
281+ if isinstance (a, sympy.Dummy):
282+ return Dummy(a.name, a.dummy_index)
283+ elif isinstance (a, sympy.Symbol):
282284 return Symbol(a.name)
283- elif isinstance (a, sympy.Dummy):
284- return Dummy(a.name)
285285 elif isinstance (a, sympy.Mul):
286286 return mul(* [sympy2symengine(x, raise_error) for x in a.args])
287287 elif isinstance (a, sympy.Add):
@@ -1304,10 +1304,10 @@ cdef class Symbol(Expr):
13041304 return sympy.Symbol(str (self ))
13051305
13061306 def __reduce__ (self ):
1307- if type (self ) == Symbol:
1307+ if type (self ) in ( Symbol, Dummy) :
13081308 return Basic.__reduce__(self )
13091309 else :
1310- raise NotImplementedError (" pickling for Symbol subclass not implemented" )
1310+ raise NotImplementedError (" pickling for subclass of Symbol or Dummy not implemented" )
13111311
13121312 def _sage_ (self ):
13131313 import sage.all as sage
@@ -1340,15 +1340,20 @@ cdef class Symbol(Expr):
13401340
13411341cdef class Dummy(Symbol):
13421342
1343- def __init__ (Basic self , name = None , *args , **kwargs ):
1344- if name is None :
1345- self .thisptr = symengine.make_rcp_Dummy()
1343+ def __init__ (Basic self , name = None , dummy_index = None , *args , **kwargs ):
1344+ cdef size_t index
1345+ if dummy_index is None :
1346+ if name is None :
1347+ self .thisptr = symengine.make_rcp_Dummy()
1348+ else :
1349+ self .thisptr = symengine.make_rcp_Dummy(name.encode(" utf-8" ))
13461350 else :
1347- self .thisptr = symengine.make_rcp_Dummy(name.encode(" utf-8" ))
1351+ index = dummy_index
1352+ self .thisptr = symengine.make_rcp_Dummy(name.encode(" utf-8" ), index)
13481353
13491354 def _sympy_ (self ):
13501355 import sympy
1351- return sympy.Dummy(str ( self )[ 1 :] )
1356+ return sympy.Dummy(name = self .name, dummy_index = self .dummy_index )
13521357
13531358 @property
13541359 def is_Dummy (self ):
@@ -1358,6 +1363,12 @@ cdef class Dummy(Symbol):
13581363 def func (self ):
13591364 return self .__class__
13601365
1366+ @property
1367+ def dummy_index (self ):
1368+ cdef RCP[const symengine.Dummy] this = \
1369+ symengine.rcp_static_cast_Dummy(self .thisptr)
1370+ cdef size_t index = deref(this).get_index()
1371+ return index
13611372
13621373def symarray (prefix , shape , **kwargs ):
13631374 """ Creates an nd-array of symbols
0 commit comments