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

Function test_more_eq

tests/test_Statistics.py:95–119  ·  view source on GitHub ↗

Tests the equality operator for the same search trajectory.

(ok_small)

Source from the content-addressed store, hash-verified

93
94
95def test_more_eq(ok_small):
96 """
97 Tests the equality operator for the same search trajectory.
98 """
99 sol = Solution(ok_small, [[1, 2], [3, 4]])
100 cost_eval = CostEvaluator([20], 6, 6)
101
102 stats1 = Statistics()
103 stats2 = Statistics()
104
105 assert_equal(stats1, stats2)
106 assert_(stats1 != "str")
107
108 stats1.collect(sol, sol, sol, cost_eval)
109 assert_(stats1 != stats2)
110
111 # Now do the same thing for stats2, so they have the seen the exact same
112 # search trajectory. That, however, is not enough: the runtimes are
113 # still slightly different.
114 stats2.collect(sol, sol, sol, cost_eval)
115 assert_(stats1 != stats2)
116
117 # But once we fix that the two should be the exact same again.
118 stats2.runtimes = stats1.runtimes
119 assert_equal(stats1, stats2)
120
121
122def test_iterating_over_statistics_returns_data(ok_small):

Callers

nothing calls this directly

Calls 4

collectMethod · 0.95
SolutionClass · 0.90
CostEvaluatorClass · 0.90
StatisticsClass · 0.90

Tested by

no test coverage detected