Skip to content

Commit f7dc3be

Browse files
author
Han Wang
committed
test(dpmodel): attach_angles layout.node_capacity branch
1 parent 2ccd120 commit f7dc3be

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

source/tests/common/dpmodel/test_angle_builder.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,27 @@ def test_attach_angles_ordered_include_self():
287287
n_full = int(am_full.sum())
288288
# ordered+include_self must produce at least as many angles as default
289289
assert n_full >= n_default
290+
291+
292+
def test_attach_angles_with_layout_node_capacity():
293+
"""layout.node_capacity branch: node_capacity is used as n_total."""
294+
coord = np.array([[[0.0, 0, 0], [0.6, 0, 0], [0, 0.6, 0]]])
295+
atype = np.array([[0, 0, 0]]) # (nf, nloc)
296+
ng = build_neighbor_graph(coord, atype, None, 2.0)
297+
layout = GraphLayout(edge_capacity=100, angle_capacity=20, node_capacity=10)
298+
ng2 = attach_angles(ng, a_rcut=1.5, layout=layout)
299+
assert ng2.angle_index is not None
300+
assert ng2.angle_mask.shape == (20,)
301+
# same real-angle set as the dynamic path (node_capacity only oversizes n_total)
302+
ng3 = attach_angles(ng, a_rcut=1.5)
303+
got = {
304+
(int(ng2.angle_index[0, p]), int(ng2.angle_index[1, p]))
305+
for p in range(ng2.angle_index.shape[1])
306+
if ng2.angle_mask[p]
307+
}
308+
ref = {
309+
(int(ng3.angle_index[0, p]), int(ng3.angle_index[1, p]))
310+
for p in range(ng3.angle_index.shape[1])
311+
if ng3.angle_mask[p]
312+
}
313+
assert got == ref

0 commit comments

Comments
 (0)