Skip to content

Commit

Permalink
refactor: typings for sympy export
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Apr 28, 2024
1 parent 7113eed commit 583beaf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pysr/export_sympy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import sympy
from sympy import sympify

from .utils import ArrayLike

sympy_mappings = {
"div": lambda x, y: x / y,
"mult": lambda x, y: x * y,
Expand Down Expand Up @@ -60,21 +62,21 @@


def create_sympy_symbols_map(
feature_names_in: List[str],
feature_names_in: ArrayLike[str],
) -> Dict[str, sympy.Symbol]:
return {variable: sympy.Symbol(variable) for variable in feature_names_in}


def create_sympy_symbols(
feature_names_in: List[str],
feature_names_in: ArrayLike[str],
) -> List[sympy.Symbol]:
return [sympy.Symbol(variable) for variable in feature_names_in]


def pysr2sympy(
equation: str,
*,
feature_names_in: Optional[List[str]] = None,
feature_names_in: Optional[ArrayLike[str]] = None,
extra_sympy_mappings: Optional[Dict[str, Callable]] = None,
):
if feature_names_in is None:
Expand Down

0 comments on commit 583beaf

Please sign in to comment.