Skip to content

Commit

Permalink
reverting a change in create_python_function
Browse files Browse the repository at this point in the history
  • Loading branch information
rimjhimittal committed Mar 21, 2024
1 parent cdbf8ab commit 2718670
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/modeci_mdf/functions/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ def substitute_args(expression_string: str = None, args: Dict[str, str] = None)
return expression_string


def create_python_function(name: str, expression_string: str, arguments: List[str]) -> types.FunctionType:
def create_python_function(
name: str = None,
expression_string: str = None,
arguments: List[str] = None,
) -> "types.FunctionType":
"""Create a Python function e.g. linear, exponential, sin, cos, ReLu
Args:
Expand All @@ -133,7 +137,7 @@ def create_python_function(name: str, expression_string: str, arguments: List[st
# assumes expression is one line
name = name.replace(":", "_")
expr = create_python_expression(expression_string)
func_str = f"def {name}({','.join(arguments)}):\n\treturn {expression_string}"
func_str = f"def {name}({','.join(arguments)}):\n\treturn {expr}"

res = {}
exec(func_str, globals(), res)
Expand Down

0 comments on commit 2718670

Please sign in to comment.