Skip to content

Commit

Permalink
add name property to FunctionSymbol
Browse files Browse the repository at this point in the history
  • Loading branch information
isuruf committed Jan 23, 2024
1 parent a7136d7 commit a165060
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions symengine/lib/symengine_wrapper.in.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2841,6 +2841,10 @@ class FunctionSymbol(Function):
name = deref(X).get_name().decode("utf-8")
return str(name)

@property
def name(Basic self):
return self.get_name()

def _sympy_(self):
import sympy
name = self.get_name()
Expand Down
5 changes: 4 additions & 1 deletion symengine/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,15 @@ def test_derivative():

def test_function():
x = Symbol("x")
assert Function("f")(x) == function_symbol("f", x)
fx = Function("f")(x)
assert fx == function_symbol("f", x)

raises(TypeError, lambda: Function("f", "x"))
raises(TypeError, lambda: Function("f", x))
raises(TypeError, lambda: Function())

assert fx.name == "f"


def test_abs():
x = Symbol("x")
Expand Down

0 comments on commit a165060

Please sign in to comment.