Skip to content

Commit

Permalink
Adding back test for matrix consistency.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Eric Nitschke committed May 19, 2023
1 parent 5df6c49 commit d8f9fe4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
5 changes: 2 additions & 3 deletions awpy/parser/demoparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,9 +789,8 @@ def renumber_frames(self) -> None:
self.logger.error(
"JSON not found. Run .parse() or .read_json() if JSON already exists"
)
raise AttributeError(
"JSON not found. Run .parse() or .read_json() if JSON already exists"
)
msg = "JSON not found. Run .parse() or .read_json() if JSON already exists"
raise AttributeError(msg)

def rescore_rounds(self) -> None:
"""Rescore the rounds based on round end reason.
Expand Down
25 changes: 24 additions & 1 deletion tests/test_nav.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
token_state_distance,
tree,
)
from awpy.data import NAV, create_nav_graphs
from awpy.data import NAV, PLACE_DIST_MATRIX, create_nav_graphs


class TestNav:
Expand Down Expand Up @@ -799,6 +799,29 @@ def test_generate_place_distance_matrix(self):
with pytest.raises(ValueError, match="Map not found."):
_ = generate_place_distance_matrix("de_does_not_exist")

with patch("awpy.analytics.nav.AREA_DIST_MATRIX", {}):
for map_name in PLACE_DIST_MATRIX:
result_matrix = generate_place_distance_matrix(
map_name=map_name, save=False
)
for place1_name in PLACE_DIST_MATRIX[map_name]:
for place2_name in PLACE_DIST_MATRIX[map_name][place1_name]:
for dist_type in PLACE_DIST_MATRIX[map_name][place1_name][
place2_name
]:
for ref_point in ["centroid", "representative_point"]:
assert (
PLACE_DIST_MATRIX[map_name][place1_name][
place2_name
][dist_type][ref_point]
== result_matrix[place1_name][place2_name][
dist_type
][ref_point]
), (
f"{map_name}, {place1_name}, {place2_name},"
f" {dist_type}, {ref_point}"
)

def test_generate_centroids(self):
"""Tests generate centroids."""
with pytest.raises(ValueError, match="Map not found."):
Expand Down

0 comments on commit d8f9fe4

Please sign in to comment.