diff --git a/tests/common/general_maths/test_arithmetic_conversions.py b/tests/common/general_maths/test_arithmetic_conversions.py index 6a69519692..ffba7d18e7 100644 --- a/tests/common/general_maths/test_arithmetic_conversions.py +++ b/tests/common/general_maths/test_arithmetic_conversions.py @@ -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", diff --git a/tests/common/general_maths/test_check_bounds.py b/tests/common/general_maths/test_check_bounds.py index 2ce0dc7042..1633b19ff6 100644 --- a/tests/common/general_maths/test_check_bounds.py +++ b/tests/common/general_maths/test_check_bounds.py @@ -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( @@ -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( @@ -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( diff --git a/tests/common/general_maths/test_transmission_interconversion.py b/tests/common/general_maths/test_transmission_interconversion.py index db3fa31293..40622d9c48 100644 --- a/tests/common/general_maths/test_transmission_interconversion.py +++ b/tests/common/general_maths/test_transmission_interconversion.py @@ -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):