From f6d8749547c94e1f6b82cba43fd5bb333010c7f6 Mon Sep 17 00:00:00 2001 From: Ben Ruijl Date: Mon, 22 Apr 2024 10:28:43 +0200 Subject: [PATCH] Add get_symbol for functions in Python API - This allows for easier pattern restrictions on function wildcards --- src/api/python.rs | 5 +++++ symbolica.pyi | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/api/python.rs b/src/api/python.rs index 769779fb..fc11c4bb 100644 --- a/src/api/python.rs +++ b/src/api/python.rs @@ -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 diff --git a/symbolica.pyi b/symbolica.pyi index a644450c..ea190592 100644 --- a/symbolica.pyi +++ b/symbolica.pyi @@ -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: """