Skip to content

Commit 082798c

Browse files
author
Han Wang
committed
test(dpmodel): angle_padding_fraction total==0 branch
1 parent d762883 commit 082798c

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

source/tests/common/dpmodel/test_angle_builder.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,3 +432,24 @@ def test_angle_padding_fraction():
432432

433433
# No angles → fraction is 0.0
434434
assert angle_padding_fraction(g_bare) == 0.0
435+
436+
437+
def test_angle_padding_fraction_total_zero():
438+
"""angle_padding_fraction returns 0.0 when angle_mask.shape[0] == 0.
439+
440+
This exercises the `if total == 0: return 0.0` branch in angle_padding_fraction.
441+
A graph with angle_capacity=0 and a_rcut too small for any angles produces
442+
angle_mask with shape (0,).
443+
"""
444+
# Create a layout with angle_capacity=0 and use a_rcut=0.01 (too small
445+
# for any edge in the fixture to pass the distance gate)
446+
layout = GraphLayout(angle_capacity=0)
447+
g_bare, g_with = _small_graph_with_angles(a_rcut=0.01, layout=layout)
448+
449+
# Verify angle_mask exists and has shape (0,)
450+
assert g_with.angle_mask is not None
451+
assert g_with.angle_mask.shape[0] == 0
452+
453+
# angle_padding_fraction must return 0.0 for empty mask
454+
result = angle_padding_fraction(g_with)
455+
assert result == 0.0

0 commit comments

Comments
 (0)