From c6264bdf980179e6efce226672fb5bfb013be7d2 Mon Sep 17 00:00:00 2001 From: Jack Atkinson Date: Sun, 17 Nov 2024 15:44:12 +0000 Subject: [PATCH] Bugfix: Restrict shorter peg rounds to Archery tier as per the rules in the new 2025 field classifications. --- .../agb_field_classifications.py | 9 +++++ .../classifications/tests/test_agb_field.py | 39 ++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/archeryutils/classifications/agb_field_classifications.py b/archeryutils/classifications/agb_field_classifications.py index 15fb491..31ee950 100644 --- a/archeryutils/classifications/agb_field_classifications.py +++ b/archeryutils/classifications/agb_field_classifications.py @@ -31,6 +31,7 @@ class GroupData(TypedDict): classes_long: list[str] class_HC: npt.NDArray[np.float64] max_distance: int + min_dists: npt.NDArray[np.float64] def _make_agb_field_classification_dict() -> dict[str, GroupData]: @@ -103,6 +104,10 @@ def _make_agb_field_classification_dict() -> dict[str, GroupData]: class_hc = np.empty(classifications_count) + min_dists = np.empty(classifications_count) + min_dists[0:6] = dists[0] + min_dists[6:9] = [max(dists[0] - 10 * i, 30) for i in range(1, 4)] + for i in range(classifications_count): # Assign handicap for this classification class_hc[i] = ( @@ -116,6 +121,7 @@ def _make_agb_field_classification_dict() -> dict[str, GroupData]: "classes_long": agb_classes_field_long, "class_HC": class_hc, "max_distance": dists[1], + "min_dists": min_dists, } classification_dict[groupname] = groupdata @@ -333,6 +339,9 @@ def agb_field_classification_scores( round_max_dist = ALL_FIELD_ROUNDS[roundname].max_distance().value for i in range(len(class_scores)): # What classes are eligible based on category and distance + # Is round too short? + if group_data["min_dists"][i] > round_max_dist: + class_scores[i] = -9999 # Is peg too long (i.e. red peg for unsighted)? if group_data["max_distance"] < round_max_dist: class_scores[i] = -9999 diff --git a/archeryutils/classifications/tests/test_agb_field.py b/archeryutils/classifications/tests/test_agb_field.py index 5fe6297..d66c52d 100644 --- a/archeryutils/classifications/tests/test_agb_field.py +++ b/archeryutils/classifications/tests/test_agb_field.py @@ -239,13 +239,34 @@ class TestCalculateAgbFieldClassification: "compound", "GMB", ), - ( + ( # Bowman classifications only on 12-target rounds "wa_field_12_red_marked", 200, "adult", "compound", "B1", ), + ( # Archer classifications only on shorter rounds - A1 + "wa_field_24_blue_marked", + 400, + "adult", + "compound", + "A1", + ), + ( # Archer classifications only on shorter rounds - A2 + "wa_field_24_yellow_marked", + 400, + "adult", + "compound", + "A2", + ), + ( # Archer classifications only on shorter rounds - A3 + "wa_field_24_white_marked", + 400, + "adult", + "compound", + "A3", + ), ( "wa_field_24_red_marked", 337, @@ -281,13 +302,27 @@ class TestCalculateAgbFieldClassification: "traditional", "UC", ), - ( + ( # Bowman classifications only on 12-target rounds "wa_field_12_blue_marked", 88, "Under 18", "traditional", "B1", ), + ( # Archer classifications only on shorter rounds - Junior + "wa_field_24_yellow_marked", + 400, + "Under 18", + "traditional", + "A1", + ), + ( # Archer classifications only on shorter rounds - Junior + "wa_field_24_white_marked", + 400, + "Under 18", + "traditional", + "A2", + ), ( "wa_field_24_blue_marked", 143,