Skip to content

Commit

Permalink
ENH: mark @unevaluated arguments as non-sympy (#380)
Browse files Browse the repository at this point in the history
* ENH: implement `unevaluated` with `dataclasses`
* ENH: implement `__slots__` for non-sympy arguments
* ENH: implement `pickle` support
* ENH: do not overwrite `_eval_subs` if no non-sympy attributes
  • Loading branch information
redeboer authored Dec 21, 2023
1 parent b76435c commit e341327
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 90 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
add_module_names = False
api_github_repo = f"{ORGANIZATION}/{REPO_NAME}"
api_target_substitutions: dict[str, str | tuple[str, str]] = {
"T": "TypeVar",
"BuilderReturnType": ("obj", "ampform.dynamics.builder.BuilderReturnType"),
"DecoratedClass": ("obj", "ampform.sympy.DecoratedClass"),
"DecoratedExpr": ("obj", "ampform.sympy.DecoratedExpr"),
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ task-tags = ["cspell"]
[tool.ruff.isort]
known-third-party = ["sympy"]

[tool.ruff.lint.flake8-bugbear]
extend-immutable-calls = [
"ampform.sympy._decorator.argument",
]

[tool.ruff.per-file-ignores]
"**/docs/usage/sympy.ipynb" = ["E731"]
"*.ipynb" = [
Expand Down
3 changes: 3 additions & 0 deletions src/ampform/sympy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Tools that facilitate in building :mod:`sympy` expressions.
.. autodecorator:: unevaluated
.. autofunction:: argument
.. dropdown:: SymPy assumptions
.. autodata:: ExprClass
Expand Down Expand Up @@ -30,6 +32,7 @@
from ._decorator import (
ExprClass, # noqa: F401 # pyright: ignore[reportUnusedImport]
SymPyAssumptions, # noqa: F401 # pyright: ignore[reportUnusedImport]
argument, # noqa: F401 # pyright: ignore[reportUnusedImport]
unevaluated, # noqa: F401 # pyright: ignore[reportUnusedImport]
)

Expand Down
Loading

0 comments on commit e341327

Please sign in to comment.