Skip to content

Commit da429c6

Browse files
authored
test routing null matrix validation (#1220)
DataModel.add_cost_matrix routes through validate_matrix, which is expected to reject matrices containing NULL values before solve-time logic. This change adds a focused negative test to lock down that contract and prevent silent regressions during future validation. ### Summary - Add test_dist_mat_null to routing validation coverage. - Cover the NULL input path for cost matrices in DataModel.add_cost_matrix. Authors: - Daniel T. (https://github.com/aycsi) - Ramakrishna Prabhu (https://github.com/ramakrishnap-nv) - Trevor McKay (https://github.com/tmckayus) Approvers: - Trevor McKay (https://github.com/tmckayus) URL: #1220
1 parent 91134a2 commit da429c6

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

python/cuopt/cuopt/tests/routing/test_warnings_exceptions.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ def test_dist_mat():
7575
)
7676

7777

78+
def test_dist_mat_null():
79+
cost_matrix = cudf.DataFrame(
80+
[
81+
[0, 5.0, 5.0, 5.0],
82+
[5.0, 0, 5.0, 5.0],
83+
[5.0, 5.0, 0, 5.0],
84+
[5.0, None, 5.0, 0],
85+
]
86+
)
87+
with pytest.raises(Exception) as exc_info:
88+
dm = routing.DataModel(cost_matrix.shape[0], 3)
89+
dm.add_cost_matrix(cost_matrix)
90+
assert str(exc_info.value) == "cost matrix cannot have NULL values"
91+
92+
7893
def test_time_windows():
7994
cost_matrix = cudf.DataFrame(
8095
[

0 commit comments

Comments
 (0)