Tests that each route's center point is the center point of all clients visited by that route.
(ok_small)
| 292 | |
| 293 | |
| 294 | def 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 | |
| 314 | def test_route_can_be_pickled(rc208): |