Skip to content

Add attribute to Dummy: dummy_index #517

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion symengine/lib/symengine.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ cdef extern from "<symengine/basic.h>" namespace "SymEngine":
RCP[const Rational] rcp_static_cast_Rational "SymEngine::rcp_static_cast<const SymEngine::Rational>"(rcp_const_basic &b) nogil
RCP[const Complex] rcp_static_cast_Complex "SymEngine::rcp_static_cast<const SymEngine::Complex>"(rcp_const_basic &b) nogil
RCP[const Number] rcp_static_cast_Number "SymEngine::rcp_static_cast<const SymEngine::Number>"(rcp_const_basic &b) nogil
RCP[const Dummy] rcp_static_cast_Dummy "SymEngine::rcp_static_cast<const SymEngine::Dummy>"(rcp_const_basic &b) nogil
RCP[const Add] rcp_static_cast_Add "SymEngine::rcp_static_cast<const SymEngine::Add>"(rcp_const_basic &b) nogil
RCP[const Mul] rcp_static_cast_Mul "SymEngine::rcp_static_cast<const SymEngine::Mul>"(rcp_const_basic &b) nogil
RCP[const Pow] rcp_static_cast_Pow "SymEngine::rcp_static_cast<const SymEngine::Pow>"(rcp_const_basic &b) nogil
Expand Down Expand Up @@ -180,7 +181,7 @@ cdef extern from "<symengine/symbol.h>" namespace "SymEngine":
Symbol(string name) nogil
string get_name() nogil
cdef cppclass Dummy(Symbol):
pass
size_t get_index()

cdef extern from "<symengine/number.h>" namespace "SymEngine":
cdef cppclass Number(Basic):
Expand Down
6 changes: 6 additions & 0 deletions symengine/lib/symengine_wrapper.in.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,12 @@ cdef class Dummy(Symbol):
def func(self):
return self.__class__

@property
def dummy_index(self):
cdef RCP[const symengine.Dummy] this = \
symengine.rcp_static_cast_Dummy(self.thisptr)
cdef size_t index = deref(this).get_index()
return index

def symarray(prefix, shape, **kwargs):
""" Creates an nd-array of symbols
Expand Down
1 change: 1 addition & 0 deletions symengine/tests/test_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def test_dummy():
x2 = Symbol('x')
xdummy1 = Dummy('x')
xdummy2 = Dummy('x')
assert xdummy1.dummy_index != xdummy2.dummy_index # maybe test using "less than"?

assert x1 == x2
assert x1 != xdummy1
Expand Down
Loading