Skip to content

Commit

Permalink
Update typing and close assertions in tests as suggested by @LiamPatt…
Browse files Browse the repository at this point in the history
  • Loading branch information
jatkinson1000 committed Jul 15, 2024
1 parent 1bfbd16 commit 4625170
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
4 changes: 2 additions & 2 deletions archeryutils/classifications/agb_outdoor_classifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
agb_outdoor_classification_scores
"""

from typing import Any, Literal, Optional, TypedDict, cast
from typing import Any, Literal, TypedDict, cast

import numpy as np
import numpy.typing as npt
Expand Down Expand Up @@ -575,7 +575,7 @@ def agb_outdoor_classification_fraction( # noqa: PLR0913 Too many arguments
bowstyle: str,
gender: str,
age_group: str,
restrict: Optional[bool] = True,
restrict: bool | None = True,
) -> float:
"""
Calculate the fraction towards the next classification an archer is.
Expand Down
17 changes: 9 additions & 8 deletions archeryutils/classifications/tests/test_agb_indoor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests for agb indoor classification functions."""

import numpy as np
import pytest

import archeryutils as au
Expand Down Expand Up @@ -87,7 +88,7 @@ def test_agb_indoor_classification_scores_ages(
age_group=age_group,
)

assert scores == scores_expected[::-1]
np.testing.assert_allclose(scores, scores_expected[::-1])

@pytest.mark.parametrize(
"age_group,scores_expected",
Expand Down Expand Up @@ -128,7 +129,7 @@ def test_agb_indoor_classification_scores_genders(
age_group=age_group,
)

assert scores == scores_expected[::-1]
np.testing.assert_allclose(scores, scores_expected[::-1])

@pytest.mark.parametrize(
"bowstyle,scores_expected",
Expand Down Expand Up @@ -160,7 +161,7 @@ def test_agb_indoor_classification_scores_bowstyles(
age_group="adult",
)

assert scores == scores_expected[::-1]
np.testing.assert_allclose(scores, scores_expected[::-1])

@pytest.mark.parametrize(
"bowstyle,scores_expected",
Expand Down Expand Up @@ -192,7 +193,7 @@ def test_agb_indoor_classification_scores_nonbowstyles(
age_group="adult",
)

assert scores == scores_expected[::-1]
np.testing.assert_allclose(scores, scores_expected[::-1])

@pytest.mark.parametrize(
"roundname,scores_expected",
Expand Down Expand Up @@ -228,7 +229,7 @@ def test_agb_indoor_classification_scores_triple_faces(
age_group="adult",
)

assert scores == scores_expected[::-1]
np.testing.assert_allclose(scores, scores_expected[::-1])

@pytest.mark.parametrize(
"roundname,bowstyle,gender,age_group",
Expand Down Expand Up @@ -469,7 +470,7 @@ def test_agb_indoor_classification_fraction( # noqa: PLR0913 Too many arguments
age_group=age_group,
)

assert frac_returned == frac_expected
np.testing.assert_allclose(frac_returned, frac_expected)

@pytest.mark.parametrize(
"roundname,score,age_group,bowstyle,frac_expected",
Expand Down Expand Up @@ -521,7 +522,7 @@ def test_agb_indoor_classification_fraction_low( # noqa: PLR0913 many args
age_group=age_group,
)

assert frac_returned == frac_expected
np.testing.assert_allclose(frac_returned, frac_expected)

@pytest.mark.parametrize(
"roundname,score,age_group,bowstyle,frac_expected",
Expand Down Expand Up @@ -573,4 +574,4 @@ def test_agb_indoor_classification_fraction_high( # noqa: PLR0913 Too many args
age_group=age_group,
)

assert frac_returned == frac_expected
np.testing.assert_allclose(frac_returned, frac_expected)
19 changes: 10 additions & 9 deletions archeryutils/classifications/tests/test_agb_outdoor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests for agb indoor classification functions."""

import numpy as np
import pytest

import archeryutils as au
Expand Down Expand Up @@ -97,7 +98,7 @@ def test_agb_outdoor_classification_scores_ages(
age_group=age_group,
)

assert scores == scores_expected[::-1]
np.testing.assert_allclose(scores, scores_expected[::-1])

@pytest.mark.parametrize(
"roundname,age_group,scores_expected",
Expand Down Expand Up @@ -143,7 +144,7 @@ def test_agb_outdoor_classification_scores_genders(
age_group=age_group,
)

assert scores == scores_expected[::-1]
np.testing.assert_allclose(scores, scores_expected[::-1])

@pytest.mark.parametrize(
"roundname,bowstyle,gender,scores_expected",
Expand Down Expand Up @@ -201,7 +202,7 @@ def test_agb_outdoor_classification_scores_bowstyles(
age_group="adult",
)

assert scores == scores_expected[::-1]
np.testing.assert_allclose(scores, scores_expected[::-1])

@pytest.mark.parametrize(
"roundname,bowstyle,gender,scores_expected",
Expand Down Expand Up @@ -241,7 +242,7 @@ def test_agb_outdoor_classification_scores_nonbowstyles(
age_group="adult",
)

assert scores == scores_expected[::-1]
np.testing.assert_allclose(scores, scores_expected[::-1])

@pytest.mark.parametrize(
"roundname,scores_expected",
Expand Down Expand Up @@ -269,7 +270,7 @@ def test_agb_outdoor_classification_scores_triple_faces(
age_group="adult",
)

assert scores == scores_expected[::-1]
np.testing.assert_allclose(scores, scores_expected[::-1])

@pytest.mark.parametrize(
"roundname,bowstyle,gender,age_group",
Expand Down Expand Up @@ -621,7 +622,7 @@ def test_agb_outdoor_classification_fraction( # noqa: PLR0913 many args
age_group=age_group,
)

assert frac_returned == frac_expected
np.testing.assert_allclose(frac_returned, frac_expected)

@pytest.mark.parametrize(
"roundname,score,age_group,bowstyle,frac_expected",
Expand Down Expand Up @@ -673,7 +674,7 @@ def test_agb_outdoor_classification_fraction_low( # noqa: PLR0913 many args
age_group=age_group,
)

assert frac_returned == frac_expected
np.testing.assert_allclose(frac_returned, frac_expected)

@pytest.mark.parametrize(
"roundname,score,age_group,bowstyle,frac_expected",
Expand Down Expand Up @@ -725,7 +726,7 @@ def test_agb_outdoor_classification_fraction_high( # noqa: PLR0913 many args
age_group=age_group,
)

assert frac_returned == frac_expected
np.testing.assert_allclose(frac_returned, frac_expected)

def test_agb_outdoor_classification_fraction_restrict(
self,
Expand All @@ -749,4 +750,4 @@ def test_agb_outdoor_classification_fraction_restrict(
restrict=False,
)

assert frac_unrestricted == 0.4541258975704667
np.testing.assert_allclose(frac_unrestricted, 0.4541258975704667)

0 comments on commit 4625170

Please sign in to comment.