Skip to content

Commit

Permalink
ENH: remove xxhash dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Dec 19, 2024
1 parent df3efb1 commit ac518cd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 113 deletions.
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ test = [
"pytest-cov",
"pytest-profiling",
"pytest-xdist",
"xxhash",
]
types = [
"ipython",
Expand All @@ -120,7 +119,6 @@ types = [
"sphinx-api-relink",
"types-PyYAML",
"types-setuptools",
"xxhash",
]

[tool.setuptools]
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_topology.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import hashlib
import pickle # noqa: S403
import typing

import pytest
import xxhash
from attrs.exceptions import FrozenInstanceError
from IPython.lib.pretty import pretty

Expand Down Expand Up @@ -44,10 +44,10 @@ def test_immutability(self):
class TestFrozenDict:
def test_hash(self):
obj: FrozenDict = FrozenDict({})
assert _compute_hash(obj) == "458fa667e2b581f54c06f5d6f85a0329"
assert _compute_hash(obj) == "067705e70d037311d05daae1e32e1fce"

obj = FrozenDict({"key1": "value1"})
assert _compute_hash(obj) == "ebbfce37fe77355d4e07479243089a6f"
assert _compute_hash(obj) == "56b0520e2a3af550c0f488cd5de2d474"

obj = FrozenDict({
"key1": "value1",
Expand Down Expand Up @@ -208,7 +208,7 @@ def test_constructor_exceptions(self, nodes, edges):
assert Topology(nodes, edges)

def test_hash(self, two_to_three_decay: Topology):
assert _compute_hash(two_to_three_decay) == "5f55e8b64bcb177cf0984c985d8673fa"
assert _compute_hash(two_to_three_decay) == "cbaea5d94038a3ad30888014a7b3ae20"

@pytest.mark.parametrize("repr_method", [repr, pretty])
def test_repr_and_eq(self, repr_method, two_to_three_decay: Topology):
Expand Down Expand Up @@ -325,7 +325,7 @@ def test_create_n_body_topology(n_initial: int, n_final: int, exception):

def _compute_hash(obj) -> str:
b = _to_bytes(obj)
h = xxhash.xxh128(b)
h = hashlib.md5(b) # noqa: S324
return h.hexdigest()


Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_transition.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# pyright: reportUnusedImport=false
import hashlib
import pickle # noqa: S403
from copy import deepcopy
from fractions import Fraction

import pytest
import xxhash
from IPython.lib.pretty import pretty

from qrules.particle import Parity, Particle, ParticleCollection, Spin # noqa: F401
Expand Down Expand Up @@ -46,10 +46,10 @@ def test_repr(self, repr_method, reaction: ReactionInfo):
def test_hash(self, reaction: ReactionInfo):
assert hash(deepcopy(reaction)) == hash(reaction)

def test_xxhash(self, reaction: ReactionInfo):
def test_hash_value(self, reaction: ReactionInfo):
expected_hash = {
"canonical-helicity": "de995528a15267dd3a72fe6c5dfa6136",
"helicity": "61c08ea813390cfbae8b083a89a5673a",
"canonical-helicity": "65106a44301f9340e633d09f66ad7d17",
"helicity": "9646d3ee5c5e8534deb8019435161f2e",
}[reaction.formalism]
assert _compute_hash(reaction) == expected_hash

Expand Down Expand Up @@ -119,7 +119,7 @@ def test_regex_pattern(self):

def _compute_hash(obj) -> str:
b = _to_bytes(obj)
h = xxhash.xxh128(b)
h = hashlib.md5(b) # noqa: S324
return h.hexdigest()


Expand Down
Loading

0 comments on commit ac518cd

Please sign in to comment.