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

Function test_route_centroid

tests/test_Route.py:294–311  ·  view source on GitHub ↗

Tests that each route's center point is the center point of all clients visited by that route.

(ok_small)

Source from the content-addressed store, hash-verified

292
293
294def test_route_centroid(ok_small):
295 """
296 Tests that each route's center point is the center point of all clients
297 visited by that route.
298 """
299 x = np.array([ok_small.location(idx).x for idx in range(5)])
300 y = np.array([ok_small.location(idx).y for idx in range(5)])
301
302 routes = [
303 Route(ok_small, [1, 2], 0),
304 Route(ok_small, [3], 0),
305 Route(ok_small, [4], 0),
306 ]
307
308 for route in routes:
309 x_center, y_center = route.centroid()
310 assert_allclose(x_center, x[route].mean())
311 assert_allclose(y_center, y[route].mean())
312
313
314def test_route_can_be_pickled(rc208):

Callers

nothing calls this directly

Calls 2

RouteClass · 0.90
locationMethod · 0.80

Tested by

no test coverage detected