Skip to content

Commit

Permalink
Mark subs as throwing exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
isuruf committed Jul 25, 2024
1 parent 9ce6c5a commit 8f6f7a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions symengine/lib/symengine.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ cdef extern from "<symengine/basic.h>" namespace "SymEngine":
void cse(vec_pair &replacements, vec_basic &reduced_exprs, const vec_basic &exprs) except+ nogil

cdef extern from "<symengine/subs.h>" namespace "SymEngine":
rcp_const_basic msubs (rcp_const_basic &x, const map_basic_basic &x) nogil
rcp_const_basic ssubs (rcp_const_basic &x, const map_basic_basic &x) nogil
rcp_const_basic xreplace (rcp_const_basic &x, const map_basic_basic &x) nogil
rcp_const_basic msubs (rcp_const_basic &x, const map_basic_basic &x) except+ nogil
rcp_const_basic ssubs (rcp_const_basic &x, const map_basic_basic &x) except+ nogil
rcp_const_basic xreplace (rcp_const_basic &x, const map_basic_basic &x) except+ nogil

cdef extern from "<symengine/derivative.h>" namespace "SymEngine":
rcp_const_basic diff "SymEngine::sdiff"(rcp_const_basic &arg, rcp_const_basic &x) except+ nogil
Expand Down
8 changes: 7 additions & 1 deletion symengine/tests/test_subs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest

from symengine.test_utilities import raises
from symengine import Symbol, sin, cos, sqrt, Add, function_symbol, have_numpy
from symengine import Symbol, sin, cos, sqrt, Add, function_symbol, have_numpy, log


def test_basic():
Expand All @@ -24,6 +24,12 @@ def test_sin():
assert e.subs(x, 0) == 1


def test_subs_exception():
x = Symbol("x")
expr = sin(log(x))
raises(RuntimeError, lambda: expr.subs({x: 0}))


def test_args():
x = Symbol("x")
e = cos(x)
Expand Down

0 comments on commit 8f6f7a3

Please sign in to comment.