io#

Input-output functions for ampform and sympy objects.

This module extends AmpForm’s aslatex() function. You can register more implementations as follows:

>>> from ampform_dpd.io import aslatex
>>> @aslatex.register(int)
... def _(obj: int) -> str:
...     return "my custom rendering"
>>> aslatex(1)
'my custom rendering'
>>> aslatex(3.4 - 2j)
'3.4-2i'

This code originates from ComPWA/ampform#280.

as_markdown_table(obj: Sequence) str[source]#

Render objects a str suitable for generating a table.

perform_cached_lambdify(expr: Expr, backend: str = 'jax', directory: str | None = None) PositionalArgumentFunction[source]#
perform_cached_lambdify(expr: Expr, parameters: Mapping[Symbol, ParameterValue], backend: str = 'jax', directory: str | None = None) ParametrizedBackendFunction

Lambdify a SymPy Expr and cache the result to disk.

The cached result is fetched from disk if the hash of the expression is the same as the hash embedded in the filename.

Parameters:

Tip

For a faster cache, set PYTHONHASHSEED to a fixed value.

simplify_latex_rendering() None[source]#

Improve LaTeX rendering of an Indexed object.