22
33from __future__ import annotations
44
5- import hashlib
6-
75import pytest
86
97from pyglotaran_extras .inspect .kinetic_scheme ._k_matrix_parser import Transition
@@ -104,10 +102,14 @@ def test_no_overlapping_positions(self) -> None:
104102 positions = compute_layout (graph , LayoutAlgorithm .HIERARCHICAL )
105103
106104 compartment_positions = [positions [n .label ] for n in graph .compartment_nodes ()]
105+ epsilon = 1e-6
107106 for i , pos_i in enumerate (compartment_positions ):
108107 for j , pos_j in enumerate (compartment_positions ):
109108 if i != j :
110- assert pos_i != pos_j
109+ dx = pos_i [0 ] - pos_j [0 ]
110+ dy = pos_i [1 ] - pos_j [1 ]
111+ distance = (dx * dx + dy * dy ) ** 0.5
112+ assert distance > epsilon
111113
112114 def test_deterministic_output (self ) -> None :
113115 """Same input should always produce the same positions."""
@@ -120,12 +122,11 @@ def test_deterministic_output(self) -> None:
120122
121123 def test_node_sort_index_is_deterministic (self ) -> None :
122124 """Node sort index should use deterministic hashing."""
123- label = "species_2"
124- digest = hashlib .md5 (label .encode (), usedforsecurity = False ).digest ()
125- expected = int .from_bytes (digest [:4 ], "big" ) / 4294967296.0
126- actual = _node_sort_index (label )
127- assert actual == expected
128- assert 0.0 <= actual < 1.0
125+ species_2_idx = _node_sort_index ("species_2" )
126+ species_3_idx = _node_sort_index ("species_3" )
127+ assert 0.0 <= species_2_idx < 1.0
128+ assert 0.0 <= species_3_idx < 1.0
129+ assert species_2_idx != species_3_idx
129130
130131 def test_parallel_nodes_side_by_side (self ) -> None :
131132 """Parallel decay nodes (all isolated) should be on the same row."""
0 commit comments