Tests that when using ``ProblemData.replace()`` without any arguments returns a new instance with different objects, but with the same values.
()
| 280 | |
| 281 | |
| 282 | def test_problem_data_replace_no_changes(): |
| 283 | """ |
| 284 | Tests that when using ``ProblemData.replace()`` without any arguments |
| 285 | returns a new instance with different objects, but with the same values. |
| 286 | """ |
| 287 | clients = [Client(x=0, y=0)] |
| 288 | depots = [Depot(x=0, y=0)] |
| 289 | vehicle_types = [VehicleType()] |
| 290 | mat = np.zeros((2, 2), dtype=int) |
| 291 | original = ProblemData(clients, depots, vehicle_types, [mat], [mat]) |
| 292 | |
| 293 | new = original.replace() |
| 294 | |
| 295 | assert_(new is not original) |
| 296 | |
| 297 | for idx in range(new.num_clients): |
| 298 | assert_(new.location(idx) is not original.location(idx)) |
| 299 | assert_equal(new.location(idx).x, original.location(idx).x) |
| 300 | assert_equal(new.location(idx).y, original.location(idx).y) |
| 301 | |
| 302 | for idx in range(new.num_vehicle_types): |
| 303 | new_veh_type = new.vehicle_type(idx) |
| 304 | orig_veh_type = original.vehicle_type(idx) |
| 305 | |
| 306 | assert_(new_veh_type is not orig_veh_type) |
| 307 | assert_equal(new_veh_type.capacity, orig_veh_type.capacity) |
| 308 | assert_equal(new_veh_type.num_available, orig_veh_type.num_available) |
| 309 | |
| 310 | new_dist = new.distance_matrix(profile=0) |
| 311 | orig_dist = original.distance_matrix(profile=0) |
| 312 | assert_(new_dist is not orig_dist) |
| 313 | assert_equal(new_dist, orig_dist) |
| 314 | |
| 315 | new_dur = new.duration_matrix(profile=0) |
| 316 | orig_dur = original.duration_matrix(profile=0) |
| 317 | assert_(new_dur is not orig_dur) |
| 318 | assert_equal(new_dur, orig_dur) |
| 319 | |
| 320 | assert_equal(new.num_clients, original.num_clients) |
| 321 | assert_equal(new.num_vehicle_types, original.num_vehicle_types) |
| 322 | assert_equal(new.num_load_dimensions, original.num_load_dimensions) |
| 323 | |
| 324 | |
| 325 | def test_problem_data_replace_with_changes(): |
nothing calls this directly
no test coverage detected