MCPcopy Create free account
hub / github.com/PyVRP/PyVRP / test_fields_are_correctly_set

Function test_fields_are_correctly_set

tests/test_Result.py:16–31  ·  view source on GitHub ↗

Tests that ``Result``'s data properties are correctly set after initialisation completes.

(ok_small, routes, num_iterations, runtime)

Source from the content-addressed store, hash-verified

14 [([[1, 2], [3], [4]], 1, 1.5), ([[1, 2, 3, 4]], 100, 54.2)],
15)
16def test_fields_are_correctly_set(ok_small, routes, num_iterations, runtime):
17 """
18 Tests that ``Result``'s data properties are correctly set after
19 initialisation completes.
20 """
21 sol = Solution(ok_small, routes)
22 res = Result(sol, Statistics(), num_iterations, runtime)
23
24 assert_equal(res.is_feasible(), sol.is_feasible())
25 assert_equal(res.num_iterations, num_iterations)
26 assert_allclose(res.runtime, runtime)
27
28 if sol.is_feasible():
29 assert_equal(res.cost(), CostEvaluator([0], 0, 0).cost(sol))
30 else:
31 assert_equal(res.cost(), math.inf)
32
33
34@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 6

is_feasibleMethod · 0.95
costMethod · 0.95
SolutionClass · 0.90
ResultClass · 0.90
StatisticsClass · 0.90
CostEvaluatorClass · 0.90

Tested by

no test coverage detected