Tests that the data matrices provided by ``distance_matrix()`` and ``duration_matrix()`` are not writeable. They can be read from, but assigning new values should raise an error. We require this because they're constant on the C++ side, and allowing changes from Python causes u
()
| 432 | |
| 433 | |
| 434 | def test_matrices_are_not_writeable(): |
| 435 | """ |
| 436 | Tests that the data matrices provided by ``distance_matrix()`` and |
| 437 | ``duration_matrix()`` are not writeable. They can be read from, but |
| 438 | assigning new values should raise an error. |
| 439 | |
| 440 | We require this because they're constant on the C++ side, and allowing |
| 441 | changes from Python causes undefined behaviour on the C++ side. |
| 442 | """ |
| 443 | data = ProblemData( |
| 444 | clients=[], |
| 445 | depots=[Depot(x=0, y=0)], |
| 446 | vehicle_types=[VehicleType(2)], |
| 447 | distance_matrices=[np.array([[0]])], |
| 448 | duration_matrices=[np.array([[0]])], |
| 449 | ) |
| 450 | |
| 451 | dist_mat = data.distance_matrix(profile=0) |
| 452 | dur_mat = data.duration_matrix(profile=0) |
| 453 | |
| 454 | with assert_raises(ValueError): |
| 455 | dist_mat[0, 0] = 1_000 |
| 456 | |
| 457 | with assert_raises(ValueError): |
| 458 | dur_mat[0, 0] = 1_000 |
| 459 | |
| 460 | |
| 461 | def test_matrices_are_not_copies(): |
nothing calls this directly
no test coverage detected