Skip to content

Commit

Permalink
Merge branch 'main' into modernize-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer authored Oct 11, 2024
2 parents 747b89f + e43f66c commit f3672cf
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 262 deletions.
245 changes: 0 additions & 245 deletions .constraints/py3.8.txt

This file was deleted.

2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@
"ampform_dpd.decay.StateIDTemplate": ("obj", "ampform_dpd.decay.StateID"),
"ampform_dpd.io.serialization.dynamics.T": "typing.TypeVar",
"DecayNode": ("obj", "ampform_dpd.decay.DecayNode"),
"EdgeType": "typing.TypeVar",
"FinalState": ("obj", "ampform_dpd.decay.FinalState"),
"FinalStateID": ("obj", "ampform_dpd.decay.FinalStateID"),
"FrozenTransition": "qrules.topology.FrozenTransition",
"InitialStateID": ("obj", "ampform_dpd.decay.InitialStateID"),
"Literal[-1, 1]": "typing.Literal",
"Literal[(-1, 1)]": "typing.Literal",
"Node": ("obj", "ampform_dpd.io.serialization.format.Node"),
"NodeType": "typing.TypeVar",
"ParameterValue": ("obj", "tensorwaves.interface.ParameterValue"),
"ParametrizedBackendFunction": "tensorwaves.function.ParametrizedBackendFunction",
"PoolSum": "ampform.sympy.PoolSum",
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python",
"Topic :: Scientific/Engineering :: Physics",
Expand All @@ -38,7 +37,7 @@ description = "Symbolic expressions for Dalitz-Plot Decomposition"
dynamic = ["version"]
license = {file = "LICENSE"}
name = "ampform-dpd"
requires-python = ">=3.8"
requires-python = ">=3.9"

[project.optional-dependencies]
dev = [
Expand Down
6 changes: 3 additions & 3 deletions src/ampform_dpd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from collections import abc
from functools import lru_cache
from functools import cache
from itertools import product
from typing import Any, Literal, Protocol
from warnings import warn
Expand Down Expand Up @@ -289,7 +289,7 @@ def _create_coupling_symbol(
return H[resonance, interaction.L, interaction.S]


@lru_cache(maxsize=None)
@cache
def _get_coupling_base(
helicity_coupling: bool, typ: Literal["production", "decay"]
) -> sp.IndexedBase:
Expand Down Expand Up @@ -331,7 +331,7 @@ def _formulate_clebsch_gordan_factors(
return sqrt_factor * cg_ll * cg_ss


@lru_cache(maxsize=None)
@cache
def _generate_amplitude_index_bases() -> dict[FinalStateID, sp.IndexedBase]:
return dict(enumerate(sp.symbols(R"A^(1:4)", cls=sp.IndexedBase), 1)) # type:ignore[arg-type]

Expand Down
4 changes: 3 additions & 1 deletion src/ampform_dpd/_attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Iterable, SupportsFloat
from typing import TYPE_CHECKING, SupportsFloat

import sympy as sp

if TYPE_CHECKING:
from collections.abc import Iterable

from attrs import Attribute

from ampform_dpd.decay import LSCoupling, ThreeBodyDecayChain
Expand Down
2 changes: 1 addition & 1 deletion src/ampform_dpd/_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _get_python_hash_seed() -> int | None:
return None


@functools.lru_cache(maxsize=None) # warn once
@functools.cache # warn once
def _warn_about_unsafe_hash() -> None:
message = """
PYTHONHASHSEED has not been set. For faster and safer hashing of SymPy expressions,
Expand Down
5 changes: 4 additions & 1 deletion src/ampform_dpd/adapter/qrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections import abc, defaultdict
from functools import singledispatch
from pathlib import Path
from typing import Any, Iterable, NoReturn, TypeVar, overload
from typing import TYPE_CHECKING, Any, NoReturn, TypeVar, overload

import attrs
import qrules
Expand All @@ -24,6 +24,9 @@
ThreeBodyDecayChain,
)

if TYPE_CHECKING:
from collections.abc import Iterable

_LOGGER = logging.getLogger(__name__)


Expand Down
6 changes: 3 additions & 3 deletions src/ampform_dpd/decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from functools import lru_cache
from functools import cache
from textwrap import dedent
from typing import TYPE_CHECKING, Generic, Literal, TypeVar, overload
from warnings import warn
Expand Down Expand Up @@ -170,7 +170,7 @@ def initial_state(self) -> InitialState:
return self.parent

@property
@lru_cache(maxsize=None) # noqa: B019
@cache # noqa: B019
def final_state(self) -> tuple[FinalState, FinalState, FinalState]:
final_state = (*self.decay_products, self.spectator)
return tuple(sorted(final_state, key=lambda x: x.index)) # type:ignore[return-value]
Expand Down Expand Up @@ -202,7 +202,7 @@ def decay_products(self) -> tuple[FinalState, FinalState]:
def spectator(self) -> FinalState:
return self._get_child_of_type(State)

@lru_cache(maxsize=None) # noqa: B019
@cache # noqa: B019
def _get_child_of_type(self, typ: type[T]) -> T:
for child in self.decay.children:
if isinstance(child, typ):
Expand Down
4 changes: 3 additions & 1 deletion src/ampform_dpd/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from collections import abc
from importlib.metadata import version
from pathlib import Path
from typing import TYPE_CHECKING, Any, Iterable, Mapping, Sequence, overload
from typing import TYPE_CHECKING, Any, overload

import cloudpickle
import sympy as sp
Expand All @@ -41,6 +41,8 @@
)

if TYPE_CHECKING:
from collections.abc import Iterable, Mapping, Sequence

from tensorwaves.function import (
ParametrizedBackendFunction,
PositionalArgumentFunction,
Expand Down
Loading

0 comments on commit f3672cf

Please sign in to comment.