Skip to content

Commit

Permalink
MAINT: remove partial_doit() from symplot
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Mar 3, 2025
1 parent 946dc92 commit be6a4a7
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions src/symplot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
from ipywidgets.widgets import FloatSlider, IntSlider
from sympy.printing.latex import translate

from ampform.sympy import (
partial_doit, # noqa: F401 # pyright: ignore[reportUnusedImport]
)

if TYPE_CHECKING: # pragma: no cover
import sys
from collections.abc import Iterator, Mapping, Sequence
Expand Down Expand Up @@ -311,26 +315,6 @@ def __safe_wrap_symbols(
raise TypeError(msg)


def partial_doit(
expression: sp.Expr,
doit_classes: type[sp.Basic] | tuple[type[sp.Basic], ...],
) -> sp.Expr:
"""Perform :meth:`~sympy.core.basic.Basic.doit` up to a certain level.
Arguments
---------
expression: the `~sympy.core.expr.Expr` on which you want to perform a
:meth:`~sympy.core.basic.Basic.doit`.
doit_classes: types on which the :meth:`~sympy.core.basic.Basic.doit` should be
performed.
"""
new_expression = expression
for node in sp.preorder_traversal(expression):
if isinstance(node, doit_classes):
new_expression = new_expression.xreplace({node: node.doit(deep=False)})
return new_expression


def _indexed_to_symbol(idx: sp.Indexed) -> sp.Symbol:
base_name, _, _ = str(idx).rpartition("[")
subscript = ",".join(map(str, idx.indices))
Expand Down

0 comments on commit be6a4a7

Please sign in to comment.