Skip to content

Commit 58f771f

Browse files
author
Han Wang
committed
fix(docs+review): numpydoc See Also->Notes for C++ cross-refs; address CodeQL/CodeRabbit
- RTD build failed: numpydoc's strict See Also parser rejected the C++-twin cross-reference prose entries ('Error parsing See Also entry ...'). Move the cross-refs to Notes sections (free-form reST) in apply_pair_exclusion and apply_pair_exclusion_nlist. - main.py: drop stale 'no type exclusion' from the graph-eligibility comment (exclude_types is now graph-native; matches the docstring + ValueError). - test_graph_atomic_parity: remove dead ds/ft/am chain (CodeQL unused 'am'). - test_neighbor_graph_builder: drop redundant local 'import unittest' (CodeQL).
1 parent 1b5c75d commit 58f771f

5 files changed

Lines changed: 19 additions & 22 deletions

File tree

deepmd/dpmodel/utils/neighbor_graph/graph.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,15 @@ def apply_pair_exclusion(
211211
A ``dataclasses.replace`` copy (or the original ``graph`` on early
212212
exit) with the exclusion applied.
213213
214-
See Also
215-
--------
216-
C++ twin ``applyPairExclusion`` in ``source/api_cc/include/commonPT.h``
217-
The inference-path mirror. Same argument order (edge_index, edge_mask,
218-
atype, ...), same variable names (``type_ij``, ``keep``): it computes
219-
``type_ij = atype[dst]*(ntypes+1) + atype[src]`` and ANDs the flat
220-
``(ntypes+1)^2`` table lookup into ``edge_mask`` (mask-only mode; no
221-
compact variant on the compiled path).
214+
Notes
215+
-----
216+
The C++ inference-path mirror is ``applyPairExclusion`` in
217+
``source/api_cc/include/commonPT.h``. It uses the same argument order
218+
(edge_index, edge_mask, atype, ...) and the same variable names
219+
(``type_ij``, ``keep``): it computes
220+
``type_ij = atype[dst]*(ntypes+1) + atype[src]`` and ANDs the flat
221+
``(ntypes+1)^2`` table lookup into ``edge_mask`` (mask-only mode; no
222+
compact variant on the compiled path).
222223
"""
223224
import dataclasses
224225

deepmd/dpmodel/utils/nlist.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,6 @@ def apply_pair_exclusion_nlist(
9292
This is the nlist-representation counterpart of
9393
:func:`deepmd.dpmodel.utils.neighbor_graph.apply_pair_exclusion`.
9494
95-
See Also
96-
--------
97-
C++ twin ``applyPairExclusionNlist`` in ``source/api_cc/include/commonPT.h``
98-
The inference-path mirror. Same argument order (nlist, atype_ext, ...),
99-
same variable names (``type_ij``, ``keep``): it computes ``type_ij``
100-
from the center/neighbor types via the flat ``(ntypes+1)^2`` table and
101-
replaces excluded entries with ``-1``.
102-
10395
Parameters
10496
----------
10597
nlist : Array
@@ -115,6 +107,15 @@ def apply_pair_exclusion_nlist(
115107
Array
116108
Neighbor list of the same shape with excluded entries set to ``-1``.
117109
Erasing ``-1`` entries a second time is a no-op (idempotent).
110+
111+
Notes
112+
-----
113+
The C++ inference-path mirror is ``applyPairExclusionNlist`` in
114+
``source/api_cc/include/commonPT.h``. It uses the same argument order
115+
(nlist, atype_ext, ...) and the same variable names (``type_ij``,
116+
``keep``): it computes ``type_ij`` from the center/neighbor types via
117+
the flat ``(ntypes+1)^2`` table and replaces excluded entries with
118+
``-1``.
118119
"""
119120
if pair_excl is None or len(pair_excl.exclude_types) == 0:
120121
return nlist

deepmd/pt_expt/entrypoints/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def freeze(
569569
m.eval()
570570

571571
# The graph lower is opt-in and only valid for graph-eligible models
572-
# (dpa1 with concat tebd and no type exclusion; attention layers included
572+
# (dpa1 with concat tebd, incl. attention layers and exclude_types
573573
# -- the carry-all pair enumeration exports via unbacked SymInts). Fail
574574
# fast with a clear message rather than emitting a broken .pt2. Enable the
575575
# per-atom virial for the graph form -- it is near-free there (one extra

source/tests/common/dpmodel/test_graph_atomic_parity.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,6 @@ def test_apply_pair_exclusion_idempotent(pair_exclude_types):
326326
rng = np.random.default_rng(42)
327327
coord = rng.normal(size=(1, 5, 3)) * 1.5
328328
atype = np.array([[0, 1, 0, 1, 0]], dtype=np.int64)
329-
ds = DescrptDPA1(rcut=4.0, rcut_smth=0.5, sel=[200], ntypes=2, attn_layer=0)
330-
ft = InvarFitting("energy", 2, ds.get_dim_out(), 1, mixed_types=True)
331-
am = DPAtomicModel(ds, ft, type_map=["a", "b"])
332329
ext_coord, ext_atype, mapping, nlist = extend_input_and_build_neighbor_list(
333330
coord, atype, 4.0, [200], mixed_types=True, box=None
334331
)

source/tests/common/dpmodel/test_neighbor_graph_builder.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,6 @@ def setUpClass(cls) -> None:
421421
try:
422422
import ase # noqa: F401
423423
except ImportError as e:
424-
import unittest
425-
426424
raise unittest.SkipTest("ase not installed") from e
427425

428426
def setUp(self) -> None:

0 commit comments

Comments
 (0)