MCPcopy Index your code
hub / github.com/PyVRP/PyVRP / test_matrix_access

Function test_matrix_access

tests/test_ProblemData.py:409–431  ·  view source on GitHub ↗

Tests that the ``duration_matrix()`` and ``distance_matrix()`` methods correctly return the underlying data matrices.

()

Source from the content-addressed store, hash-verified

407
408
409def test_matrix_access():
410 """
411 Tests that the ``duration_matrix()`` and ``distance_matrix()`` methods
412 correctly return the underlying data matrices.
413 """
414 gen = default_rng(seed=42)
415 size = 6
416
417 dist_mat = gen.integers(500, size=(size, size))
418 dur_mat = gen.integers(500, size=(size, size))
419 np.fill_diagonal(dist_mat, 0)
420 np.fill_diagonal(dur_mat, 0)
421
422 data = ProblemData(
423 clients=[Client(x=0, y=0, tw_late=10) for _ in range(size - 1)],
424 depots=[Depot(x=0, y=0)],
425 vehicle_types=[VehicleType(2)],
426 distance_matrices=[dist_mat],
427 duration_matrices=[dur_mat],
428 )
429
430 assert_equal(data.distance_matrix(profile=0), dist_mat)
431 assert_equal(data.duration_matrix(profile=0), dur_mat)
432
433
434def test_matrices_are_not_writeable():

Callers

nothing calls this directly

Calls 4

ProblemDataClass · 0.90
ClientClass · 0.90
DepotClass · 0.90
VehicleTypeClass · 0.90

Tested by

no test coverage detected