Skip to content

Commit

Permalink
Bugfix: Restrict shorter peg rounds to Archery tier as per the rules …
Browse files Browse the repository at this point in the history
…in the new 2025 field classifications.
  • Loading branch information
jatkinson1000 committed Nov 17, 2024
1 parent 29e2451 commit c6264bd
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
9 changes: 9 additions & 0 deletions archeryutils/classifications/agb_field_classifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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] = (
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
39 changes: 37 additions & 2 deletions archeryutils/classifications/tests/test_agb_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c6264bd

Please sign in to comment.