Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Round narrows #111

Merged
merged 3 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions archeryutils/rounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ class Round:
string identifing the governing body the round belongs to
family : str or None
string identifing the family the round belongs to (e.g. wa1440, western, etc.)
n_arrows : int
total number of arrows in this round

Examples
--------
Expand Down Expand Up @@ -214,6 +216,7 @@ def __init__(
self.location = location
self.body = body
self.family = family
self.n_arrows: int = sum(pass_i.n_arrows for pass_i in self.passes)

def __repr__(self) -> str:
"""Return a representation of a Round instance."""
Expand Down
35 changes: 35 additions & 0 deletions archeryutils/tests/test_rounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,41 @@ def test_equality_different_object(self) -> None:

assert round_ != ("Test", [pass_, pass_])

@pytest.mark.parametrize(
"passes,result",
[
pytest.param(
[
Pass.at_target(100, "5_zone", 122, 50, False),
Pass.at_target(100, "5_zone", 122, 40, False),
Pass.at_target(100, "5_zone", 122, 30, False),
],
300,
),
pytest.param(
[
Pass.at_target(100, "5_zone", 122, 50, False),
],
100,
),
pytest.param(
[
Pass.at_target(100, "5_zone", 122, 50, False),
Pass.at_target(50, "5_zone", 122, 40, False),
Pass.at_target(25, "5_zone", 80, 30, False),
],
175,
),
],
)
def test_n_arrows(self, passes: Iterable, result: int) -> None:
"""Check that n_arrows attribute is calculated correctly for a Round."""
test_round = Round(
"MyRound",
passes,
)
assert test_round.n_arrows == result

def test_max_score(self) -> None:
"""Check that max score is calculated correctly for a Round."""
test_round = Round(
Expand Down
9 changes: 9 additions & 0 deletions docs/develop/whats-new.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
What's New
==========

Latest
------
* Adds `n_arrows` attribute to `Round`.
* Fixes issue whereby a divide-by-zero warning could arise in the handicap rootfinding
algorithm.
* Update to latest ruff and mypy.
* Bugfix: Field classification naming made consistent with other schemes.


Version 1.1.1
-------------
* Fixes a bug in version 1.1.0 whereby shorter-peg rounds were not restricted to
Expand Down
Loading