Skip to content

Commit

Permalink
TEST: implement hash test for FrozenDict
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Dec 19, 2024
1 parent 7bcf84b commit 8a9a171
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/sympy/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest
import qrules
import sympy as sp
from qrules.topology import FrozenDict

from ampform import get_builder
from ampform.dynamics import EnergyDependentWidth
Expand Down Expand Up @@ -95,3 +96,20 @@ def test_amplitude_model(self, expected_hash: str, formalism: SpinFormalism):
builder.dynamics.assign(name, create_relativistic_breit_wigner_with_ff)
model = builder.formulate()
assert get_readable_hash(model.expression) == expected_hash


class TestFrozenDict:
def test_qrules_frozen_dict(self):
obj: FrozenDict = FrozenDict({})
assert get_readable_hash(obj) == "023f1d9cf3576a46b278007d6e5cb0fa"

obj = FrozenDict({"key1": "value1"})
assert get_readable_hash(obj) == "076915d85252aa5c87f63702437c6dbd"

obj = FrozenDict({
"key1": "value1",
"key2": 2,
"key3": (1, 2, 3),
"key4": FrozenDict({"nested_key": "nested_value"}),
})
assert get_readable_hash(obj) == "c3b3a661e63f57003fc3deea5d23ede9"

0 comments on commit 8a9a171

Please sign in to comment.