Skip to content
Open
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
21 changes: 21 additions & 0 deletions tests/common/general_maths/test_arithmetic_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,27 @@ def test_conversion_from_microns_to_centimetres(input, result):
assert convert_microns_to_cm(input) == pytest.approx(result)


# Circular tests (all numbers here arbitrary)


@pytest.mark.parametrize("input", [1.0, 10.0, 100.0])
def test_circular_cm_to_mm_and_back(input):
assert convert_cm_to_mm(convert_mm_to_cm(input)) == input
assert convert_mm_to_cm(convert_cm_to_mm(input)) == input


@pytest.mark.parametrize("input", [1.0, 10.0, 100.0])
def test_circular_microns_to_mm_and_back(input):
assert convert_microns_to_mm(convert_mm_to_microns(input)) == input
assert convert_mm_to_microns(convert_microns_to_mm(input)) == input


@pytest.mark.parametrize("input", [1.0, 10.0, 100.0])
def test_circular_percentage_to_factor(input):
assert convert_percentage_to_factor(convert_factor_to_percentage(input)) == input
assert convert_factor_to_percentage(convert_percentage_to_factor(input)) == input


# The inauspicuous path
@pytest.mark.parametrize(
"bad_input",
Expand Down
21 changes: 3 additions & 18 deletions tests/common/general_maths/test_check_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ def test_has_misordered_inputs():
@pytest.mark.parametrize(
"bad_input",
[
(
"a",
None,
math.sin,
object(),
),
("a", None, math.sin, object(), False),
],
)
def test_is_within_range_raises_error_with_bad_tested_value(
Expand All @@ -66,12 +61,7 @@ def test_is_within_range_raises_error_with_bad_tested_value(
@pytest.mark.parametrize(
"bad_input",
[
(
"a",
None,
math.sin,
object(),
),
("a", None, math.sin, object(), False),
],
)
def test_is_within_range_raises_error_with_bad_upper_bound(
Expand All @@ -84,12 +74,7 @@ def test_is_within_range_raises_error_with_bad_upper_bound(
@pytest.mark.parametrize(
"bad_input",
[
(
"a",
None,
math.sin,
object(),
),
("a", None, math.sin, object(), False),
],
)
def test_is_within_range_raises_error_with_bad_lower_bound(
Expand Down
29 changes: 29 additions & 0 deletions tests/common/general_maths/test_transmission_interconversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,35 @@ def test_attenuation_from_natural_log_of_transmission(ln_t, result):
assert attenuation_from_natural_log_of_transmission(ln_t) == pytest.approx(result)


# Circular tests (all numbers here arbitrary)


@pytest.mark.parametrize("input", [1.0, 10.0, 100.0])
def test_circular_attenuation_from_log_and_back(input):
assert (
attenuation_from_natural_log_of_transmission(
natural_log_of_transmission_from_attenuation(input)
)
== input
)
assert (
natural_log_of_transmission_from_attenuation(
attenuation_from_natural_log_of_transmission(input)
)
== input
)


@pytest.mark.parametrize("input", [1.0, 10.0, 100.0])
def test_circular_attenuation_from_transmission_and_back(input):
assert attenuation_from_transmission(
transmission_from_attenutation(input)
) == pytest.approx(input)
assert transmission_from_attenutation(
attenuation_from_transmission(input)
) == pytest.approx(input)


# inauspicious:
@pytest.mark.parametrize("bad_input", ["a", [], None, math.sin, object(), False])
def test_natural_log_of_transmission_from_attenuation_raises_error(bad_input):
Expand Down
Loading