Skip to content

Commit

Permalink
ENH: use TypeVar on cached.doit() signature
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Mar 3, 2025
1 parent 73d67ae commit fd844f3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/ampform/sympy/cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,28 @@

if TYPE_CHECKING:
from collections.abc import Mapping
from typing import TypeVar

import sympy as sp

SympyObject = TypeVar("SympyObject", bound=sp.Basic)


@cache_to_disk
def doit(unevaluated_expr: sp.Expr) -> sp.Expr:
def doit(expr: SympyObject) -> SympyObject:
"""Perform :meth:`~sympy.core.basic.Basic.doit` and cache the result to disk.
The cached result is fetched from disk if the hash of the original expression is the
same as the hash embedded in the filename (see :func:`.get_readable_hash`).
Args:
unevaluated_expr: A `sympy.Expr <sympy.core.expr.Expr>` on which to call
expr: A `sympy.Expr <sympy.core.expr.Expr>` on which to call
:meth:`~sympy.core.basic.Basic.doit`.
.. versionadded:: 0.14.4
.. automodule:: ampform.sympy._cache
"""
return unevaluated_expr.doit()
return expr.doit()

Check warning on line 32 in src/ampform/sympy/cached.py

View check run for this annotation

Codecov / codecov/patch

src/ampform/sympy/cached.py#L32

Added line #L32 was not covered by tests


@cache_to_disk
Expand Down

0 comments on commit fd844f3

Please sign in to comment.