GraphAtoms 3.0.0__tar.gz → 3.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. {graphatoms-3.0.0 → graphatoms-3.1.1}/PKG-INFO +2 -1
  2. {graphatoms-3.0.0 → graphatoms-3.1.1}/pyproject.toml +3 -1
  3. {graphatoms-3.0.0 → graphatoms-3.1.1}/pyproject.toml.orig +8 -6
  4. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/geometry/__init__.py +0 -4
  5. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/geometry/_bond_list.py +8 -32
  6. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/geometry/_inner_outer.py +25 -5
  7. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/system/bonds.py +134 -10
  8. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/system/graph.py +190 -12
  9. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/system/sysCluster.py +7 -4
  10. graphatoms-3.0.0/src/graphatoms/geometry/_distance_pairs.py +0 -306
  11. graphatoms-3.0.0/src/graphatoms/geometry/_neighbor_list.py +0 -287
  12. {graphatoms-3.0.0 → graphatoms-3.1.1}/README.md +0 -0
  13. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/LICENSE +0 -0
  14. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/__init__.py +0 -0
  15. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/arrayapi/__init__.py +0 -0
  16. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/arrayapi/compat.py +0 -0
  17. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/arrayapi/typing.py +0 -0
  18. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/dataclasses/__init__.py +0 -0
  19. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/dataclasses/_numpydantic.py +0 -0
  20. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/dataclasses/_pydantic2pyarrow.py +0 -0
  21. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/dataclasses/_pydanticMixin.py +0 -0
  22. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/dataclasses/_pydanticModel.py +0 -0
  23. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/dataclasses/graph.py +0 -0
  24. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/geometry/itlee.py +0 -0
  25. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/geometry/mic.py +0 -0
  26. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/geometry/rotation.py +0 -0
  27. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/geometry/sample.py +0 -0
  28. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/system/__init__.py +0 -0
  29. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/system/atoms.py +0 -0
  30. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/system/database/__init__.py +0 -0
  31. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/system/database/abc.py +0 -0
  32. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/system/database/dict.py +0 -0
  33. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/system/database/dir.py +0 -0
  34. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/system/database/hdf5.py +0 -0
  35. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/system/database/sqliteASE.py +0 -0
  36. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/system/sysGas.py +0 -0
  37. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/system/system.py +0 -0
  38. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/utils/__init__.py +0 -0
  39. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/utils/bytestool.py +0 -0
  40. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/utils/parser.py +0 -0
  41. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/utils/rdutils.py +0 -0
  42. {graphatoms-3.0.0 → graphatoms-3.1.1}/src/graphatoms/utils/subgraph.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graphatoms
3
- Version: 3.0.0
3
+ Version: 3.1.1
4
4
  Summary: The Chemical Core Class for Graph Theory Analysis.
5
5
  Keywords: chemistry,graph theory,reaction,event,KMC
6
6
  Author: LiuGaoyong
@@ -11,6 +11,7 @@ Classifier: Development Status :: 5 - Production/Stable
11
11
  Classifier: Topic :: Scientific/Engineering :: Chemistry
12
12
  Classifier: Intended Audience :: Science/Research
13
13
  Requires-Dist: ase
14
+ Requires-Dist: arrayff>=0.0.1
14
15
  Requires-Dist: pymatgen>2023.6
15
16
  Requires-Dist: rdkit>=2025
16
17
  Requires-Dist: numpy>=2,<3
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "graphatoms"
7
- version = "3.0.0"
7
+ version = "3.1.1"
8
8
  readme = "README.md"
9
9
  description = "The Chemical Core Class for Graph Theory Analysis."
10
10
  license-files = ["src/LICENSE"]
@@ -24,6 +24,7 @@ classifiers = [
24
24
  ]
25
25
  dependencies = [
26
26
  "ase",
27
+ "arrayff>=0.0.1",
27
28
  "pymatgen>2023.6",
28
29
  "rdkit>=2025",
29
30
  "numpy>=2,<3",
@@ -135,6 +136,7 @@ benchmark = "pytest -s src/tests-benchmark/*.py"
135
136
  [tool.pixi.dependencies]
136
137
  python = ">=3.12"
137
138
  pytest = ">=8"
139
+ arrayff = ">=0.0.1"
138
140
  array-api-compat = ">=1.15.0"
139
141
  array-api-extra = ">=0.11.0"
140
142
  array-api-strict = ">=2.5"
@@ -8,7 +8,7 @@ Repository = "https://github.com/LiuGaoyong/GraphAtoms"
8
8
  Issues = "https://github.com/LiuGaoyong/GraphAtoms/issues/"
9
9
  [project]
10
10
  name = "graphatoms"
11
- version = "3.0.0"
11
+ version = "3.1.1"
12
12
  readme = "README.md"
13
13
  description = "The Chemical Core Class for Graph Theory Analysis."
14
14
  authors = [{ name = "LiuGaoyong", email = "liugaoyong_88@163.com" }]
@@ -29,6 +29,7 @@ classifiers = [
29
29
  ]
30
30
  dependencies = [
31
31
  "ase",
32
+ "arrayff>=0.0.1",
32
33
  "pymatgen>2023.6",
33
34
  "rdkit>=2025",
34
35
  "numpy>=2,<3",
@@ -42,9 +43,9 @@ dependencies = [
42
43
  "h5py>=3.16",
43
44
  "numpydantic",
44
45
  "pydantic>=2.10",
45
- "tomli; python_version < '3.11'", # use tomllib in python>=3.11
46
- "tomli-w", # TOML writer
47
- "pyyaml>=6.0", # YAML parser
46
+ "tomli; python_version < '3.11'", # use tomllib in python>=3.11
47
+ "tomli-w", # TOML writer
48
+ "pyyaml>=6.0", # YAML parser
48
49
  "hydra-core>=1.1", # Hydra config parser
49
50
  "typing-extensions",
50
51
  ]
@@ -52,7 +53,7 @@ dependencies = [
52
53
  [dependency-groups]
53
54
  dev = [
54
55
  "ruff>=0.11",
55
- "python-snappy>=0.7.3", # More Fase Data Compression
56
+ "python-snappy>=0.7.3", # More Fase Data Compression
56
57
  "array-api-strict",
57
58
  "pytest>=8.3",
58
59
  "pytest-xdist",
@@ -127,6 +128,7 @@ benchmark = "pytest -s src/tests-benchmark/*.py"
127
128
  [tool.pixi.dependencies]
128
129
  python = ">=3.12"
129
130
  pytest = ">=8"
131
+ arrayff = ">=0.0.1"
130
132
  array-api-compat = ">=1.15.0"
131
133
  array-api-extra = ">=0.11.0"
132
134
  array-api-strict = ">=2.5"
@@ -150,4 +152,4 @@ ruff = ">=0.11"
150
152
  chemiscope = ">=0.1.0"
151
153
  pyyaml = ">=6.0"
152
154
  hydra-core = ">=1.1"
153
- typing-extensions = ">=4.12.0"
155
+ typing-extensions = ">=4.12.0"
@@ -1,8 +1,6 @@
1
1
  """Geometry."""
2
2
 
3
3
  from graphatoms.geometry._bond_list import bond_list
4
- from graphatoms.geometry._distance_pairs import distance_pairs
5
- from graphatoms.geometry._neighbor_list import neighbor_list
6
4
  from graphatoms.geometry.itlee import (
7
5
  ITLIEEResult,
8
6
  delta_from_energy_error,
@@ -15,9 +13,7 @@ __all__ = [
15
13
  "ITLIEEResult",
16
14
  "bond_list",
17
15
  "delta_from_energy_error",
18
- "distance_pairs",
19
16
  "itlee_check_permutation",
20
17
  "itlee_equiv",
21
18
  "max_safe_delta",
22
- "neighbor_list",
23
19
  ]
@@ -3,13 +3,13 @@ from typing import Literal
3
3
 
4
4
  import networkx as nx
5
5
  import numpy as np
6
+ from arrayff.neighbors import neighbor_list
6
7
  from ase import Atoms
7
8
  from ase.data import covalent_radii as COV_R
8
9
  from pymatgen.core.structure import Molecule, Structure
9
10
  from pymatgen.io.ase import AseAtomsAdaptor
10
11
  from scipy import sparse as sp
11
12
 
12
- from graphatoms.geometry._neighbor_list import neighbor_list
13
13
  from graphatoms.utils.parser import DictConfig, hydra_parse
14
14
  from graphatoms.utils.rdutils import get_adjacency_by_rdkit
15
15
 
@@ -53,7 +53,13 @@ def bond_list(
53
53
  plus_factor = cfg.get("plus_factor", 0.3)
54
54
  multiply_factor = cfg.get("multiply_factor", 1.0)
55
55
  max_d: float = 2 * np.max(COV_R[atoms.numbers]) + 5
56
- i, j, d = neighbor_list("ijd", atoms, max_d, False, bothways=False)
56
+ i, j, d = neighbor_list(
57
+ "ijd",
58
+ atoms,
59
+ max_d,
60
+ self_interaction=False,
61
+ bothways=False,
62
+ )
57
63
  deq = COV_R[atoms.numbers[i]] + COV_R[atoms.numbers[j]]
58
64
  deq = deq * multiply_factor + plus_factor
59
65
  mask = np.logical_and(1e-3 < d, d < deq)
@@ -134,33 +140,3 @@ def bond_list(
134
140
  infer_order=False,
135
141
  )
136
142
  return matrix
137
-
138
-
139
- def test_bond_order():
140
- from ase.build import molecule
141
- from ase.cluster import Octahedron
142
-
143
- atoms = molecule("CH3CH2OH")
144
- atoms = Octahedron("Cu", 3, 1)
145
- m = bond_list(atoms=atoms)
146
-
147
- m = sp.coo_array(m)
148
- edges, data = m.coords, m.data
149
- print(edges[0], edges[1], data)
150
- m2 = get_adjacency_by_rdkit(
151
- numbers=np.array(
152
- [
153
- 1
154
- if z not in (1, 5, 6, 7, 8, 9, 14, 15, 16, 17, 32, 35, 53)
155
- else z
156
- for z in atoms.numbers
157
- ]
158
- ),
159
- geometry=atoms.positions,
160
- source=edges[0],
161
- target=edges[1],
162
- order=data,
163
- infer_order=True,
164
- charge=-59,
165
- )
166
- print(m2)
@@ -1,11 +1,11 @@
1
1
  """Distance calculation factory for atomic configurations."""
2
2
 
3
3
  import numpy as np
4
+ from arrayff.neighbors import distance_pairs
4
5
  from ase.cell import Cell
5
6
  from ase.data import covalent_radii as COV_R
6
7
  from scipy import sparse as sp
7
8
 
8
- from graphatoms.geometry._distance_pairs import distance_pairs
9
9
  from graphatoms.geometry.sample import (
10
10
  fibonacci_lattice as inverse_3d_sphere_surface_sampling,
11
11
  )
@@ -31,10 +31,25 @@ def check_atom_is_inner( # noqa: D417
31
31
  bool: whether the given atom is inner.
32
32
  """
33
33
  geometry = np.asarray(geometry, dtype=float)
34
- # get neighbors of the index atom
35
- nbr = sp.coo_array(adjacency_array)
34
+ # `bond_list` stores bonds once as an upper-triangular CSR. Callers
35
+ # pass either the full matrix or a single-row slice. Either way, we
36
+ # need the symmetric view to enumerate all neighbors of `index` —
37
+ # e.g. when only row `index` is provided, an upper-triangular matrix
38
+ # would silently drop neighbors with j < index.
39
+ coo = sp.csr_matrix(adjacency_array).tocoo()
40
+ # Expand to full symmetric view within the row being queried so that
41
+ # neighbors on both sides of `index` are visible. For a full matrix
42
+ # input we pass it through unchanged (the caller may already have the
43
+ # symmetric view).
44
+ if coo.shape[0] == 1:
45
+ col = np.concatenate([coo.col, coo.row])
46
+ row = np.zeros_like(col) # all belong to row `index`
47
+ data = np.concatenate([coo.data, coo.data])
48
+ nbr = sp.coo_matrix((data, (row, col)), shape=(1, coo.shape[1]))
49
+ else:
50
+ nbr = sp.coo_matrix(adjacency_array)
36
51
  assert nbr.shape == (1, len(numbers)), nbr.shape
37
- idxs_neighbor = np.setdiff1d(nbr.coords[1], [index])
52
+ idxs_neighbor = np.setdiff1d(nbr.col, [index])
38
53
  if len(idxs_neighbor) == 0:
39
54
  return False
40
55
  else:
@@ -71,10 +86,11 @@ def check_atom_is_inner( # noqa: D417
71
86
  # Test
72
87
  #######################################################################
73
88
  def _test_inner(atoms) -> None:
74
- from ._bond_list import Atoms, bond_list
89
+ from graphatoms.geometry._bond_list import Atoms, bond_list
75
90
 
76
91
  assert isinstance(atoms, Atoms)
77
92
  m: sp.csr_matrix = bond_list(atoms)
93
+ m = m + m.T # make it symmetric
78
94
  print(len(atoms))
79
95
  for i in range(len(atoms)):
80
96
  is_inner = check_atom_is_inner(
@@ -91,3 +107,7 @@ def test_inner() -> None: # noqa: D103
91
107
  from ase.cluster import Octahedron
92
108
 
93
109
  _test_inner(Octahedron("Cu", 3, 1))
110
+
111
+
112
+ if __name__ == "__main__":
113
+ test_inner()
@@ -17,6 +17,47 @@ from graphatoms.utils.rdutils import get_rdmol
17
17
  __all__ = ["BondGraph"]
18
18
 
19
19
 
20
+ def _canonicalize_pair(pair: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
21
+ """Normalize a bond pair array to canonical upper-triangular form.
22
+
23
+ Any input shape (upper-triangular, lower-triangular, symmetric
24
+ bidirectional (i, j)/(j, i), or mixed) is reduced to exactly one row
25
+ per bond, with the convention ``(min(i, j), max(i, j))``. Rows are
26
+ then sorted ascending so the output is deterministic.
27
+
28
+ The SysGraph contract is that ``pair`` stores one row per unique bond.
29
+ Consumers that need a symmetric adjacency view build it locally (e.g.
30
+ ``MATRIX + MATRIX.T``, or feeding the single-direction edge list into
31
+ an igraph directed graph and calling ``as_undirected()``).
32
+
33
+ Args:
34
+ pair: (nbonds, 2) int32 array of atom indices.
35
+
36
+ Returns:
37
+ A tuple ``(pair, take)``. The first element is a new ``int32``
38
+ array with shape ``(n_unique_bonds, 2)`` where each row satisfies
39
+ ``row[0] < row[1]``. The second element contains, for every output
40
+ row, the index of the input row it came from, so a per-bond array
41
+ ``values`` of length ``len(pair)`` is re-aligned by
42
+ ``values[take]``.
43
+ """
44
+ pair = np.asarray(pair, dtype="int32")
45
+ # Canonicalize each edge direction to (min, max).
46
+ pair = np.sort(pair, axis=1)
47
+ # Drop symmetric (i, j)/(j, i) and accidental duplicate rows, remembering
48
+ # which input rows are equivalent afterwards.
49
+ uniq, inverse = np.unique(pair, axis=0, return_inverse=True)
50
+ # Ascending (i, j) order for deterministic serialization.
51
+ order = np.lexsort((uniq[:, 1], uniq[:, 0]))
52
+ rank = np.empty(order.size, dtype=int)
53
+ rank[order] = np.arange(order.size)
54
+ slots = rank[np.asarray(inverse).reshape(-1)]
55
+ # First input row of every output slot keeps the job of supplying the
56
+ # per-bond values, so duplicated input rows do not raise.
57
+ take = np.unique(slots, return_index=True)[1]
58
+ return uniq[order], np.asarray(take, dtype=int)
59
+
60
+
20
61
  class BondGraph(Matter, OurFrozenModel):
21
62
  coordination: Annotated[NDArray, numpy_validator("uint8")] | None = None
22
63
  pair: Annotated[NDArray, numpy_validator("int32", (-1, 2))] | None = None
@@ -31,6 +72,14 @@ class BondGraph(Matter, OurFrozenModel):
31
72
  f"Invalid shape for `{k}`: Len({k})="
32
73
  f"{len(v)} but natoms={self.natoms}."
33
74
  )
75
+ if self.pair is not None:
76
+ normalized, take = _canonicalize_pair(self.pair)
77
+ if normalized.shape != self.pair.shape or not np.array_equal(
78
+ normalized, self.pair
79
+ ):
80
+ # Frozen model — mutate via object.__setattr__.
81
+ object.__setattr__(self, "pair", normalized)
82
+ self._after_pair_canonicalized(take)
34
83
  if self.nbonds != 0:
35
84
  assert isinstance(self.pair, np.ndarray), (
36
85
  "The `pair` should be a numpy array if nbonds > 0."
@@ -60,6 +109,15 @@ class BondGraph(Matter, OurFrozenModel):
60
109
  assert self.__IGRAPH.is_simple(), "The graph should be simple."
61
110
  return self
62
111
 
112
+ def _after_pair_canonicalized(self, take: np.ndarray) -> None:
113
+ """Re-align per-bond subclass fields with the canonical ``pair``.
114
+
115
+ Called by the model validator whenever ``pair`` had to be reordered or
116
+ deduplicated; ``take[i]`` is the input row that supplies output row
117
+ ``i``. Subclasses that add a field holding one value per bond must
118
+ override this to apply ``values[take]`` to it.
119
+ """
120
+
63
121
  @override
64
122
  def _string(self) -> str:
65
123
  lst = [f"{self.nbonds}Bonds"]
@@ -328,6 +386,8 @@ class BondGraph(Matter, OurFrozenModel):
328
386
  def _weisfeiler_lehman_step(
329
387
  self,
330
388
  atomcolor: list[str | int] | np.ndarray | None = None,
389
+ distance: np.ndarray | None = None,
390
+ distance_digits: int = 2,
331
391
  ) -> np.ndarray | list[str]:
332
392
  """Return hash string for each vertex by weisfeiler lehman algorithm.
333
393
 
@@ -337,10 +397,15 @@ class BondGraph(Matter, OurFrozenModel):
337
397
  https://www.cnblogs.com/cyz666/p/9167507.html
338
398
 
339
399
  Args:
340
- digest_size (int, optional): The size of output str. Default to 6.
341
400
  atomcolor (list[str] | list[ int] | np.ndarray | None, optional):
342
401
  The vertex color in interger or string type. Defaults to None.
343
402
  If it is None, the value will be set as atomic number.
403
+ distance (np.ndarray | None, optional): one value per bond, row
404
+ aligned with ``pair``. When given, the quantized incident
405
+ bond lengths join the vertex label. Defaults to None, which
406
+ keeps the plain topology-only label.
407
+ distance_digits (int, optional): decimal places the bond lengths
408
+ are rounded to. Defaults to 2.
344
409
 
345
410
  Returns:
346
411
  np.ndarray | list[str]: the hash string for each vertex.
@@ -349,28 +414,87 @@ class BondGraph(Matter, OurFrozenModel):
349
414
  atomcolor = self.numbers
350
415
  igcolor = np.asarray(atomcolor, dtype=str)
351
416
  assert len(igcolor) == self.natoms
417
+ if distance is None:
418
+ return np.asarray(
419
+ [
420
+ hash_string(
421
+ label
422
+ + "".join(
423
+ np.sort(igcolor[self._get_neighbors_numpy(i)])
424
+ ),
425
+ )
426
+ for i, label in enumerate(igcolor)
427
+ ]
428
+ )
429
+ quantized = np.round(
430
+ np.asarray(distance, dtype="float64"), distance_digits
431
+ )
432
+ assert len(quantized) == self.nbonds, (
433
+ f"The `distance` should have {self.nbonds} values, "
434
+ f"but {len(quantized)} got."
435
+ )
436
+ incident: list[list[tuple[int, str]]] = [[] for _ in range(self.natoms)]
437
+ for (i, j), d in zip(self.P, quantized, strict=True):
438
+ text = f"{d:08.{distance_digits}f}"
439
+ incident[int(i)].append((int(j), text))
440
+ incident[int(j)].append((int(i), text))
352
441
  return np.asarray(
353
442
  [
354
443
  hash_string(
355
- label
356
- + "".join(np.sort(igcolor[self._get_neighbors_numpy(i)])),
444
+ "\x00".join(
445
+ [
446
+ label,
447
+ # Sorted multisets only: any atom/bond ordering
448
+ # must leave the label unchanged.
449
+ "|".join(sorted(igcolor[j] for j, _ in items)),
450
+ "|".join(sorted(text for _, text in items)),
451
+ ]
452
+ ),
453
+ )
454
+ for i, (label, items) in enumerate(
455
+ zip(igcolor, incident, strict=True)
357
456
  )
358
- for i, label in enumerate(igcolor)
359
457
  ]
360
458
  )
361
459
 
460
+ def _weisfeiler_lehman_labels(
461
+ self,
462
+ atomcolor: list[str | int] | np.ndarray | None = None,
463
+ hash_depth: int = 3,
464
+ distance: np.ndarray | None = None,
465
+ distance_digits: int = 2,
466
+ ) -> np.ndarray:
467
+ """Iterate the weisfeiler lehman step and return the final labels.
468
+
469
+ Unlike :meth:`get_weisfeiler_lehman_hashes` this never writes the
470
+ ``hashes`` field, so a distance-aware run cannot poison the cached
471
+ topology-only hashes.
472
+ """
473
+ labels: np.ndarray = (
474
+ np.asarray(self.__COLOR)
475
+ if atomcolor is None
476
+ else np.asarray(atomcolor, dtype=str)
477
+ )
478
+ for _ in range(hash_depth):
479
+ labels = np.asarray(
480
+ self._weisfeiler_lehman_step(
481
+ atomcolor=labels,
482
+ distance=distance,
483
+ distance_digits=distance_digits,
484
+ )
485
+ )
486
+ return labels
487
+
362
488
  @pydantic.validate_call
363
489
  def get_weisfeiler_lehman_hashes(
364
490
  self,
365
491
  hash_depth: pydantic.PositiveInt = 3,
366
492
  ) -> list[str]:
367
493
  """Return hash value for each atom."""
368
- labels = self.__COLOR
369
- for _ in range(hash_depth):
370
- labels = self._weisfeiler_lehman_step(
371
- atomcolor=np.asarray(labels),
372
- )
373
- result = [str(i) for i in labels]
494
+ result = [
495
+ str(i)
496
+ for i in self._weisfeiler_lehman_labels(hash_depth=hash_depth)
497
+ ]
374
498
  object.__setattr__(self, "hashes", result)
375
499
  assert self.hashes is not None
376
500
  return self.hashes