Skip to content

Commit

Permalink
Remove edge weight raises
Browse files Browse the repository at this point in the history
  • Loading branch information
leonlan committed Feb 13, 2023
1 parent ff6ecb5 commit 7db1712
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
28 changes: 6 additions & 22 deletions tests/parse/test_parse_distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,14 @@
)


@pytest.mark.parametrize("edge_weight_type", ["EUC_4D", "MANHATTAN", "Lnorm"])
def test_unknown_edge_weight_type(edge_weight_type):
instance = {"edge_weight_type": edge_weight_type}
with pytest.raises(ValueError):
parse_distances([], **instance)


@pytest.mark.parametrize("edge_weight_format", ["", "empty", "HALF_MATRIX"])
def test_unknown_explicit_edge_weight_format(edge_weight_format):
"""
Tests if an error is raised when an unknown edge weight format is specified
together with an ``EXPLICIT`` edge weight type.
"""
instance = {
"edge_weight_type": "EXPLICIT",
"edge_weight_format": edge_weight_format,
}
with pytest.raises(ValueError):
parse_distances([], **instance)


@pytest.mark.parametrize(
"edge_weight_type, edge_weight_format",
[("", ""), ("IMPLICIT", "LOWER_ROW"), ("TEST", "ABCD")],
[
("2D", ""), # unknown 2D type
("EXPLICIT", ""), # explicit without format
("IMPLICIT", "LOWER_ROW"), # unknown type
("TEST", "ABCD"), # unknown type and format
],
)
def test_unknown_edge_weight_type_and_format(
edge_weight_type, edge_weight_format
Expand Down
6 changes: 0 additions & 6 deletions vrplib/parse/parse_distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ def parse_distances(
np.ndarray
An n-by-n distances matrix.
"""
if edge_weight_type not in ["EUC_2D", "FLOOR_2D", "EXACT_2D", "EXPLICIT"]:
raise ValueError("Edge weight type unknown.")

if "2D" in edge_weight_type: # Euclidean distance on node coordinates
if node_coord is None:
raise ValueError(
Expand All @@ -58,9 +55,6 @@ def parse_distances(
return np.round(distance * 1000)

if edge_weight_type == "EXPLICIT":
if edge_weight_format not in ["LOWER_ROW", "FULL_MATRIX"]:
raise ValueError("Edge weight format unknown.")

if edge_weight_format == "LOWER_ROW":
# TODO Eilon instances edge weight specifications are incorrect in
# (C)VRPLIB format. Find a better way to identify Eilon instances.
Expand Down

0 comments on commit 7db1712

Please sign in to comment.