Skip to content

Commit

Permalink
Add get_symbol for functions in Python API
Browse files Browse the repository at this point in the history
- This allows for easier pattern restrictions on function wildcards
  • Loading branch information
benruijl committed Apr 22, 2024
1 parent 2e35ddc commit f6d8749
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/api/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3060,6 +3060,11 @@ impl PythonFunction {
self.id.is_symmetric()
}

/// Get the symbol of the function.
pub fn get_symbol(&self) -> PythonExpression {
Atom::new_var(self.id).into()
}

/// Create a Symbolica expression or transformer by calling the function with appropriate arguments.
///
/// Examples
Expand Down
3 changes: 3 additions & 0 deletions symbolica.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,9 @@ class Function:
def is_symmetric(self) -> bool:
"""Returns `True` iff this function is symmetric."""

def get_symbol(self) -> Expression:
"""Get the symbol of the function."""

@overload
def __call__(self, *args: Expression | int) -> Expression:
"""
Expand Down

0 comments on commit f6d8749

Please sign in to comment.