@@ -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