Repository: claritychallenge/clarity (language: python)

Issue:
Consistent use of pytest.approx in tests
We have a lot of tests that compare floating point results and are hard to reproduce on different platforms.

I think we should confine these to tests/regression and use pytest.approx in all other test modules.

This will mean that we can have a set of fast tests that are not fussy about CPU architecture that can run with,

pytest --ignore tests/regression

And we can keep the super-sensitive longer regression tests which run with GitHub actions when we merge. 

This will make it easier to test during development,  (e.g. when developing on a mac, the test suite is currently throwing lots of errors due to differences in the 8th or 9th significant fugue)



Discussion / hints:

Fix patch:
diff --git a/tests/recipes/cad1/task1/__init__.py b/recipes/cad1/task1/__init__.py
similarity index 100%
rename from tests/recipes/cad1/task1/__init__.py
rename to recipes/cad1/task1/__init__.py
diff --git a/tests/recipes/cad1/task2/__init__.py b/recipes/cad1/task2/__init__.py
similarity index 100%
rename from tests/recipes/cad1/task2/__init__.py
rename to recipes/cad1/task2/__init__.py


Test patch:
diff --git a/tests/conftest.py b/tests/conftest.py
index 2aacd20da..3f149c48d 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -15,3 +15,9 @@
 def random_matrix() -> np.ndarray:
     """Generate a random matrix for use in tests."""
     return np.asarray(rng.random((100, 100)))
+
+
+def pytest_configure() -> None:
+    """Configure custom variables for pytest"""
+    pytest.abs_tolerance = 1e-7
+    pytest.rel_tolerance = 1e-7
diff --git a/tests/data/test_HOA_tools_cec2.py b/tests/data/test_HOA_tools_cec2.py
index e1a5b6983..cbe7a132e 100644
--- a/tests/data/test_HOA_tools_cec2.py
+++ b/tests/data/test_HOA_tools_cec2.py
@@ -37,7 +37,9 @@ def test_centred_element(
     random_matrix: np.ndarray, row: int, col: int, expected: float
 ) -> None:
     """Test for centered_element() function."""
-    assert centred_element(random_matrix, row, col) == expected
+    assert centred_element(random_matrix, row, col) == pytest.approx(
+        expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_centred_element_index_error(random_matrix: np.ndarray) -> None:
@@ -61,16 +63,13 @@ def test_P(
     i: int, a: int, b: int, order: int, random_matrix: np.ndarray, expected: float
 ) -> None:
     """Test for P() function."""
-    assert (
-        P(
-            i,
-            a,
-            b,
-            order,
-            rotation_matrices=[random_matrix, random_matrix, random_matrix],
-        )
-        == expected
-    )
+    assert P(
+        i,
+        a,
+        b,
+        order,
+        rotation_matrices=[random_matrix, random_matrix, random_matrix],
+    ) == pytest.approx(expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance)
 
 
 def test_P_index_error(random_matrix: np.ndarray) -> None:
@@ -95,15 +94,12 @@ def test_U(
     degree: int, n: int, order: int, random_matrix: np.ndarray, expected: float
 ) -> None:
     """Test for U function."""
-    assert (
-        U(
-            degree,
-            n,
-            order,
-            rotation_matrices=[random_matrix, random_matrix, random_matrix],
-        )
-        == expected
-    )
+    assert U(
+        degree,
+        n,
+        order,
+        rotation_matrices=[random_matrix, random_matrix, random_matrix],
+    ) == pytest.approx(expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance)
 
 
 @pytest.mark.parametrize(
@@ -119,15 +115,12 @@ def test_V(
     degree: int, n: int, order: int, random_matrix: np.ndarray, expected: float
 ) -> None:
     """Test for V() function."""
-    assert (
-        V(
-            degree,
-            n,
-            order,
-            rotation_matrices=[random_matrix, random_matrix, random_matrix],
-        )
-        == expected
-    )
+    assert V(
+        degree,
+        n,
+        order,
+        rotation_matrices=[random_matrix, random_matrix, random_matrix],
+    ) == pytest.approx(expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance)
 
 
 @pytest.mark.parametrize(
@@ -142,15 +135,12 @@ def test_W(
     degree: int, n: int, order: int, random_matrix: np.ndarray, expected: float
 ) -> None:
     """Test for W() function."""
-    assert (
-        W(
-            degree,
-            n,
-            order,
-            rotation_matrices=[random_matrix, random_matrix, random_matrix],
-        )
-        == expected
-    )
+    assert W(
+        degree,
+        n,
+        order,
+        rotation_matrices=[random_matrix, random_matrix, random_matrix],
+    ) == pytest.approx(expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance)
 
 
 @pytest.mark.parametrize(
@@ -167,7 +157,9 @@ def test_compute_UVW_coefficients(
     degree: int, n: int, order: int, expected: float
 ) -> None:
     """Test for computer_UVW_coefficients() function."""
-    assert compute_UVW_coefficients(degree, n, order) == expected
+    assert compute_UVW_coefficients(degree, n, order) == pytest.approx(
+        expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_compute_UVW_coefficients_zero_division_error() -> None:
diff --git a/tests/data/test_utils.py b/tests/data/test_utils.py
index ed8eeea83..78bffb82c 100644
--- a/tests/data/test_utils.py
+++ b/tests/data/test_utils.py
@@ -46,7 +46,9 @@ def test_better_ear_speechweighted_snr(
     """Test of better_ear_speechweighted_snr()."""
     better_ear_signal_noise_ratio = better_ear_speechweighted_snr(target, noise)
     assert isinstance(better_ear_signal_noise_ratio, float)
-    assert better_ear_signal_noise_ratio == expected
+    assert better_ear_signal_noise_ratio == pytest.approx(
+        expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_better_ear_speechweighted_snr_noise_wrong_shape_index_error() -> None:
@@ -79,7 +81,9 @@ def test_speechweighted_snr(target: np.array, noise: np.array, expected: float)
     """Test of speechweighted_snr()."""
     signal_noise_ratio = speechweighted_snr(target, noise)
     assert isinstance(signal_noise_ratio, float)
-    assert signal_noise_ratio == expected
+    assert signal_noise_ratio == pytest.approx(
+        expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_speechweighted_snr_unequal_arrays_value_error() -> None:
diff --git a/tests/enhancer/test_nalr.py b/tests/enhancer/test_nalr.py
index 8c2e3ffff..4da3099bc 100644
--- a/tests/enhancer/test_nalr.py
+++ b/tests/enhancer/test_nalr.py
@@ -25,4 +25,6 @@
 def test_nalr(audiogram: np.ndarray, cfs: np.ndarray, expected: float) -> None:
     enhancer = NALR(**cfg_nalr)
     nalr_fir, _ = enhancer.build(audiogram, cfs)
-    assert nalr_fir[0] == expected
+    assert nalr_fir[0] == pytest.approx(
+        expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
diff --git a/tests/evaluator/haaqi/test_haaqi.py b/tests/evaluator/haaqi/test_haaqi.py
index 2a58dffca..323eedd0e 100644
--- a/tests/evaluator/haaqi/test_haaqi.py
+++ b/tests/evaluator/haaqi/test_haaqi.py
@@ -19,7 +19,9 @@ def test_haaqi_v1() -> None:
     score, _, _, _ = haaqi_v1(
         x, sample_rate, y, sample_rate, hearing_loss, equalisation_mode, level1
     )
-    assert score == pytest.approx(0.111290948, rel=1e-7)
+    assert score == pytest.approx(
+        0.111290948, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_compute_haaqi():
@@ -43,4 +45,6 @@ def test_compute_haaqi():
     )
 
     # Check that the score is a float between 0 and 1
-    assert score == pytest.approx(0.113759275, rel=1e-7)
+    assert score == pytest.approx(
+        0.113759275, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
diff --git a/tests/evaluator/haspi/test_eb.py b/tests/evaluator/haspi/test_eb.py
index e8b114b0d..389a23d60 100644
--- a/tests/evaluator/haspi/test_eb.py
+++ b/tests/evaluator/haspi/test_eb.py
@@ -64,12 +64,24 @@ def test_ear_model():
 
     # check values
     assert freq_sample == 24000
-    assert np.sum(np.abs(ref_db)) == pytest.approx(102596.63767028379)
-    assert np.sum(np.abs(proc_db)) == pytest.approx(4145.3884196835625)
-    assert np.sum(np.abs(ref_bm)) == pytest.approx(65517.72934742906)
-    assert np.sum(np.abs(proc_bm)) == pytest.approx(2366.401656815131)
-    assert np.sum(np.abs(ref_sl)) == pytest.approx(291.3527365691821)
-    assert np.sum(np.abs(proc_sl)) == pytest.approx(13.655317152968216)
+    assert np.sum(np.abs(ref_db)) == pytest.approx(
+        102596.63767028379, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(np.abs(proc_db)) == pytest.approx(
+        4145.3884196835625, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(np.abs(ref_bm)) == pytest.approx(
+        65517.72934742906, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(np.abs(proc_bm)) == pytest.approx(
+        2366.401656815131, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(np.abs(ref_sl)) == pytest.approx(
+        291.3527365691821, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(np.abs(proc_sl)) == pytest.approx(
+        13.655317152968216, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_center_frequency():
@@ -84,7 +96,9 @@ def test_center_frequency():
         min_bw=24.7,
     )
     assert center_freq.shape == (10,)
-    assert np.sum(center_freq) == pytest.approx(23935.19626226296)
+    assert np.sum(center_freq) == pytest.approx(
+        23935.19626226296, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_loss_parameters():
@@ -109,11 +123,21 @@ def test_loss_parameters():
     assert compression_ratio.shape == (6,)
     assert annenuated_ihc.shape == (6,)
     # check values
-    assert np.sum(attenuated_ohc) == pytest.approx(220.39149328167292)
-    assert np.sum(bandwith) == pytest.approx(15.041134665207498)
-    assert np.sum(low_knee) == pytest.approx(400.3914932816729)
-    assert np.sum(compression_ratio) == pytest.approx(6.0)
-    assert np.sum(annenuated_ihc) == pytest.approx(129.6085067183270)
+    assert np.sum(attenuated_ohc) == pytest.approx(
+        220.39149328167292, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(bandwith) == pytest.approx(
+        15.041134665207498, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(low_knee) == pytest.approx(
+        400.3914932816729, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(compression_ratio) == pytest.approx(
+        6.0, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(annenuated_ihc) == pytest.approx(
+        129.6085067183270, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_resample():
@@ -129,7 +153,9 @@ def test_resample():
     # check shapes
     assert len(ref_signal_24) == len(reference_signal) * 24000 / reference_freq
     # check values
-    assert np.sum(np.abs(ref_signal_24)) == pytest.approx(604.1522707137393)
+    assert np.sum(np.abs(ref_signal_24)) == pytest.approx(
+        604.1522707137393, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
     assert freq_sample_hz == 24000
 
 
@@ -146,8 +172,12 @@ def test_input_align():
 
     assert ref.shape == (600,)
     assert proc.shape == (600,)
-    assert np.sum(np.abs(ref)) == pytest.approx(29892.167176853407)
-    assert np.sum(np.abs(proc)) == pytest.approx(27199.009291096496)
+    assert np.sum(np.abs(ref)) == pytest.approx(
+        29892.167176853407, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(np.abs(proc)) == pytest.approx(
+        27199.009291096496, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_middle_ear():
@@ -158,7 +188,9 @@ def test_middle_ear():
     filtered_signal = middle_ear(reference_signal, 24000)
 
     assert filtered_signal.shape == (600,)
-    assert np.sum(np.abs(filtered_signal)) == pytest.approx(9241.220369749171)
+    assert np.sum(np.abs(filtered_signal)) == pytest.approx(
+        9241.220369749171, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_gammatone_basilar_membrane():
@@ -190,10 +222,18 @@ def test_gammatone_basilar_membrane():
     assert processed_envelope.shape == (600,)
     assert processed_basilar_membrane.shape == (600,)
     # check values
-    assert np.sum(np.abs(reference_envelope)) == pytest.approx(3605.427313705984)
-    assert np.sum(np.abs(reference_basilar_membrane)) == pytest.approx(2288.3557465)
-    assert np.sum(np.abs(processed_envelope)) == pytest.approx(4426.111706599469)
-    assert np.sum(np.abs(processed_basilar_membrane)) == pytest.approx(2804.93743475)
+    assert np.sum(np.abs(reference_envelope)) == pytest.approx(
+        3605.427313705984, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(np.abs(reference_basilar_membrane)) == pytest.approx(
+        2288.3557465, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(np.abs(processed_envelope)) == pytest.approx(
+        4426.111706599469, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(np.abs(processed_basilar_membrane)) == pytest.approx(
+        2804.93743475, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_gammatone_bandwidth_demodulation():
@@ -207,8 +247,12 @@ def test_gammatone_bandwidth_demodulation():
     )
     assert centre_freq_sin.shape == (100,)
     assert centre_freq_cos.shape == (100,)
-    assert np.sum(centre_freq_sin) == pytest.approx(-0.3791946274493412)
-    assert np.sum(centre_freq_cos) == pytest.approx(-0.39460748051808026)
+    assert np.sum(centre_freq_sin) == pytest.approx(
+        -0.3791946274493412, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(centre_freq_cos) == pytest.approx(
+        -0.39460748051808026, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 @pytest.mark.parametrize(
@@ -227,7 +271,9 @@ def test_bandwidth_adjust(scale, bw_min, bw_max, expected):
         bandwidth_max=bw_max,
         level1=1,
     )
-    assert bw_adjusted == pytest.approx(expected)
+    assert bw_adjusted == pytest.approx(
+        expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_env_compress_basilar_membrane():
@@ -253,9 +299,11 @@ def test_env_compress_basilar_membrane():
     assert compressed_signal.shape == (600,)
     assert compressed_basilar_membrane.shape == (600,)
     # check values
-    assert np.mean(np.abs(compressed_signal)) == pytest.approx(15486012153068.807)
+    assert np.mean(np.abs(compressed_signal)) == pytest.approx(
+        15486012153068.807, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
     assert np.mean(np.abs(compressed_basilar_membrane)) == pytest.approx(
-        15415471156.59357
+        15415471156.59357, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
     )
 
 
@@ -280,9 +328,13 @@ def test_envelope_align():
 
     # check shapes and values
     assert aligned_output.shape == (600,)
-    assert np.sum(np.abs(aligned_output)) == pytest.approx(299.1891022020615)
+    assert np.sum(np.abs(aligned_output)) == pytest.approx(
+        299.1891022020615, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
     # Check output is now aligned with the reference
-    assert aligned_output[100] == pytest.approx(scale * reference[100])
+    assert aligned_output[100] == pytest.approx(
+        scale * reference[100], rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 # envelope_sl
@@ -304,8 +356,12 @@ def test_envelope_sl():
 
     assert reference.shape == (600,)
     assert basilar_membrane.shape == (600,)
-    assert np.sum(np.abs(reference)) == pytest.approx(42746.12859151134)
-    assert np.sum(np.abs(basilar_membrane)) == pytest.approx(98.97646233693762)
+    assert np.sum(np.abs(reference)) == pytest.approx(
+        42746.12859151134, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(np.abs(basilar_membrane)) == pytest.approx(
+        98.97646233693762, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 # inner_hair_cell_adaptation
@@ -324,8 +380,12 @@ def test_inner_hair_cell_adaptation():
     # check shapes and values
     assert output_db.shape == (600,)
     assert output_basilar_membrane.shape == (600,)
-    assert np.sum(np.abs(output_db)) == pytest.approx(298.9359292744365)
-    assert np.sum(np.abs(output_basilar_membrane)) == pytest.approx(0.2963082865723811)
+    assert np.sum(np.abs(output_db)) == pytest.approx(
+        298.9359292744365, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(np.abs(output_basilar_membrane)) == pytest.approx(
+        0.2963082865723811, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 # basilar_membrane_add_noise
@@ -342,7 +402,9 @@ def test_basilar_membrane_add_noise():
 
     # check shapes and values and that signal has changed
     assert noisy_reference.shape == (600,)
-    assert np.sum(np.abs(noisy_reference)) == pytest.approx(298.919051930547)
+    assert np.sum(np.abs(noisy_reference)) == pytest.approx(
+        298.919051930547, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
     assert not np.allclose(noisy_reference, ref)
 
     # Check that adding on nearly 0 noise (-100 db) doesn't change the signal
@@ -371,7 +433,9 @@ def test_group_delay_compensate():
 
     # check shapes and values
     assert processed.shape == (4, 600)
-    assert np.sum(np.abs(processed)) == pytest.approx(1193.8088344682358)
+    assert np.sum(np.abs(processed)) == pytest.approx(
+        1193.8088344682358, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_convert_rms_to_sl():
@@ -396,7 +460,9 @@ def test_convert_rms_to_sl():
 
     # check shapes and values
     assert ref_db.shape == (600,)
-    assert np.sum(np.abs(ref_db)) == pytest.approx(34746.74406262155)
+    assert np.sum(np.abs(ref_db)) == pytest.approx(
+        34746.74406262155, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_env_smooth():
@@ -415,7 +481,9 @@ def test_env_smooth():
     # check shapes and values
     expected_length = 2 * sig_len / (sample_freq * segment_size / 1000)
     assert smooth.shape == (4, expected_length)
-    assert np.sum(np.abs(smooth)) == pytest.approx(100.7397658862719)
+    assert np.sum(np.abs(smooth)) == pytest.approx(
+        100.7397658862719, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_mel_cepstrum_correlation():
@@ -449,11 +517,15 @@ def test_mel_cepstrum_correlation():
 
     # check shapes and values
     assert np.array(individual_cepstral_correlation).shape == (6,)
-    assert ave_cepstral_correlation == pytest.approx(0.04195483905166838)
+    assert ave_cepstral_correlation == pytest.approx(
+        0.04195483905166838, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
     assert individual_cepstral_correlation == pytest.approx(
         np.array(
             [0.04582154, 0.04306849, 0.02364514, 0.07634693, 0.02364514, 0.04306849]
-        )
+        ),
+        rel=pytest.rel_tolerance,
+        abs=pytest.abs_tolerance,
     )
 
 
@@ -477,9 +549,15 @@ def test_melcor9():
 
     assert mel_cep_mod.shape == (8,)
 
-    assert mel_cep_ave == pytest.approx(0.07847183114015181)
-    assert mel_cep_low == pytest.approx(0.08244466051783299)
-    assert mel_cep_high == pytest.approx(0.07449900176247062)
+    assert mel_cep_ave == pytest.approx(
+        0.07847183114015181, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert mel_cep_low == pytest.approx(
+        0.08244466051783299, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert mel_cep_high == pytest.approx(
+        0.07449900176247062, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
     assert mel_cep_mod == pytest.approx(
         np.array(
             [
@@ -492,7 +570,9 @@ def test_melcor9():
                 0.06127608591547042,
                 0.009358303500341338,
             ]
-        )
+        ),
+        rel=pytest.rel_tolerance,
+        abs=pytest.abs_tolerance,
     )
 
 
@@ -514,11 +594,19 @@ def test_melcor9_equal_input():
 
     assert mel_cep_mod.shape == (8,)
 
-    assert mel_cep_ave == pytest.approx(1.0)
-    assert mel_cep_low == pytest.approx(1.0)
-    assert mel_cep_high == pytest.approx(1.0)
+    assert mel_cep_ave == pytest.approx(
+        1.0, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert mel_cep_low == pytest.approx(
+        1.0, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert mel_cep_high == pytest.approx(
+        1.0, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
     assert mel_cep_mod == pytest.approx(
-        np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
+        np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]),
+        rel=pytest.rel_tolerance,
+        abs=pytest.abs_tolerance,
     )
 
 
@@ -544,7 +632,9 @@ def test_melcor9_crosscovmatrix():
     )
 
     assert cross_cov_matrix.shape == (n_modulations, n_basis)
-    assert np.mean(cross_cov_matrix) == pytest.approx(0.9981200876213588)
+    assert np.mean(cross_cov_matrix) == pytest.approx(
+        0.9981200876213588, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_spectrum_diff():
@@ -564,13 +654,19 @@ def test_spectrum_diff():
 
     # Check values
     assert dloud == pytest.approx(
-        np.array([0.037373053253378426, 7.671407491067586e-05, 4.762048775653672e-05])
+        np.array([0.037373053253378426, 7.671407491067586e-05, 4.762048775653672e-05]),
+        rel=pytest.rel_tolerance,
+        abs=pytest.abs_tolerance,
     )
     assert dnorm == pytest.approx(
-        np.array([44.84779838405483, 0.09203844008264382, 0.0570982338215042])
+        np.array([44.84779838405483, 0.09203844008264382, 0.0570982338215042]),
+        rel=pytest.rel_tolerance,
+        abs=pytest.abs_tolerance,
     )
     assert dslope == pytest.approx(
-        np.array([0.03918063966807504, 0.00010878329523853699, 8.006096597686129e-05])
+        np.array([0.03918063966807504, 0.00010878329523853699, 8.006096597686129e-05]),
+        rel=pytest.rel_tolerance,
+        abs=pytest.abs_tolerance,
     )
 
 
@@ -597,9 +693,15 @@ def test_bm_covary_ok():
     assert proc_mean_square.shape == (4, 12)
 
     # Check values
-    assert np.sum(np.abs(signal_cross_cov)) == pytest.approx(46.43935095481214)
-    assert np.sum(np.abs(ref_mean_square)) == pytest.approx(16.65809872708418)
-    assert np.sum(np.abs(proc_mean_square)) == pytest.approx(26.110255782462076)
+    assert np.sum(np.abs(signal_cross_cov)) == pytest.approx(
+        46.43935095481214, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(np.abs(ref_mean_square)) == pytest.approx(
+        16.65809872708418, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(np.abs(proc_mean_square)) == pytest.approx(
+        26.110255782462076, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_bm_covary_error():
@@ -639,8 +741,12 @@ def test_ave_covary2():
 
     assert len(ihc_sync_covariance) == 6
 
-    assert ave_covariance == pytest.approx(0.5129961720524688)
-    assert np.sum(ihc_sync_covariance) == pytest.approx(3.057984614887033)
+    assert ave_covariance == pytest.approx(
+        0.5129961720524688, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(ihc_sync_covariance) == pytest.approx(
+        3.057984614887033, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
     assert ihc_sync_covariance == pytest.approx(
         [
@@ -650,5 +756,7 @@ def test_ave_covary2():
             0.511743935480639,
             0.5124431322756856,
             0.5126029271248499,
-        ]
+        ],
+        rel=pytest.rel_tolerance,
+        abs=pytest.abs_tolerance,
     )
diff --git a/tests/evaluator/haspi/test_ebm.py b/tests/evaluator/haspi/test_ebm.py
index 92c2e78b2..3e62c9b62 100644
--- a/tests/evaluator/haspi/test_ebm.py
+++ b/tests/evaluator/haspi/test_ebm.py
@@ -20,8 +20,12 @@ def test_env_filter_ok() -> None:
         freq_sub_sample=4000,
         freq_samp=16000,
     )
-    assert reference_env == pytest.approx(48.84481105)
-    assert processed_env == pytest.approx(32.32800458)
+    assert reference_env == pytest.approx(
+        48.84481105, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert processed_env == pytest.approx(
+        32.32800458, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 @pytest.mark.parametrize(
@@ -84,8 +88,12 @@ def test_cepstral_correlation_coef_ok() -> None:
     )
     assert ref_cep.shape == (72, n_basis)
     assert proc_cep.shape == (72, n_basis)
-    assert np.mean(np.abs(ref_cep)) == pytest.approx(82.4395877477838)
-    assert np.mean(np.abs(proc_cep)) == pytest.approx(110.74820232861624)
+    assert np.mean(np.abs(ref_cep)) == pytest.approx(
+        82.4395877477838, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.mean(np.abs(proc_cep)) == pytest.approx(
+        110.74820232861624, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_cepstral_correlation_coef_error() -> None:
@@ -141,8 +149,12 @@ def test_fir_modulation_filter() -> None:
     assert out_center_freqs.shape == in_center_freqs.shape
     # Check return value have expected values
     assert np.allclose(in_center_freqs, out_center_freqs)
-    assert np.mean(np.abs(ref_mod)) == pytest.approx(14.477262943878237)
-    assert np.mean(np.abs(proc_mod)) == pytest.approx(13.85669526424176)
+    assert np.mean(np.abs(ref_mod)) == pytest.approx(
+        14.477262943878237, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.mean(np.abs(proc_mod)) == pytest.approx(
+        13.85669526424176, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_modulation_cross_correlation() -> None:
@@ -168,4 +180,6 @@ def test_modulation_cross_correlation() -> None:
         reference_modulation=ref_mod, processed_modulation=proc_mod
     )
     assert cross_corr.shape == (n_mod_filters,)
-    assert np.sum(cross_corr) == pytest.approx(0.4414165879317118)
+    assert np.sum(cross_corr) == pytest.approx(
+        0.4414165879317118, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
diff --git a/tests/evaluator/haspi/test_haspi.py b/tests/evaluator/haspi/test_haspi.py
index 5e8dce1fd..60c12b4a1 100644
--- a/tests/evaluator/haspi/test_haspi.py
+++ b/tests/evaluator/haspi/test_haspi.py
@@ -16,7 +16,9 @@ def test_haspi_v2() -> None:
     level1 = 65
 
     score, _ = haspi_v2(x, sample_rate, y + x, sample_rate, hearing_loss, level1)
-    assert score == pytest.approx(0.043808448934532965, rel=1e-7)
+    assert score == pytest.approx(
+        0.043808448934532965, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_haspi_v2_better_ear() -> None:
@@ -45,4 +47,6 @@ def test_haspi_v2_better_ear() -> None:
         level=100,
     )
 
-    assert score == pytest.approx(0.839975335323691)
+    assert score == pytest.approx(
+        0.839975335323691, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
diff --git a/tests/evaluator/haspi/test_ip.py b/tests/evaluator/haspi/test_ip.py
index e13885e8e..2217521c9 100644
--- a/tests/evaluator/haspi/test_ip.py
+++ b/tests/evaluator/haspi/test_ip.py
@@ -43,8 +43,12 @@ def test_get_neural_net() -> None:
     assert len(weights_out) == len(weights_hidden)
     # Check the specific values of the weights are correct
     assert normalization_factor == 0.9508
-    assert np.sum(weights_out) == pytest.approx(-33.8515)
-    assert np.sum(weights_hidden) == pytest.approx(-670.8200)
+    assert np.sum(weights_out) == pytest.approx(
+        -33.8515, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(weights_hidden) == pytest.approx(
+        -670.82009999, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_nn_feed_forward_ensemble() -> None:
@@ -63,7 +67,9 @@ def test_nn_feed_forward_ensemble() -> None:
 
     # Check that the output is correct
     x = nn_feed_forward_ensemble(data, neural_net_params, weights_hidden, weights_out)
-    assert x == pytest.approx(0.95078679)
+    assert x == pytest.approx(
+        0.95078679, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_nn_feed_forward() -> None:
@@ -90,5 +96,9 @@ def test_nn_feed_forward() -> None:
     assert hidden[0] == pytest.approx(1.0)
     assert output[0] == pytest.approx(1.0)
     # Check that the mean of the hidden and output layers are correct
-    assert np.mean(hidden) == pytest.approx(0.599999906437356)
-    assert np.mean(output) == pytest.approx(0.982229820658455)
+    assert np.mean(hidden) == pytest.approx(
+        0.599999906437356, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.mean(output) == pytest.approx(
+        0.982229820658455, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
diff --git a/tests/evaluator/hasqi/test_hasqi.py b/tests/evaluator/hasqi/test_hasqi.py
index 6d5eb7ec2..2a29e799d 100644
--- a/tests/evaluator/hasqi/test_hasqi.py
+++ b/tests/evaluator/hasqi/test_hasqi.py
@@ -19,7 +19,9 @@ def test_hasqi_v2() -> None:
     score, _, _, _ = hasqi_v2(
         x, sample_rate, y, sample_rate, hearing_loss, equalisation_mode, level1
     )
-    assert score == pytest.approx(0.002525809, rel=1e-7)
+    assert score == pytest.approx(
+        0.002525809, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_hasqi_v2_better_ear() -> None:
@@ -49,4 +51,6 @@ def test_hasqi_v2_better_ear() -> None:
         audiogram_freq=None,
     )
 
-    assert score == pytest.approx(0.1256893032667640)
+    assert score == pytest.approx(
+        0.1256893032667640, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
diff --git a/tests/evaluator/mbstoi/test_mbstoi.py b/tests/evaluator/mbstoi/test_mbstoi.py
index 6a2c7fcf1..7b1e08a60 100644
--- a/tests/evaluator/mbstoi/test_mbstoi.py
+++ b/tests/evaluator/mbstoi/test_mbstoi.py
@@ -33,4 +33,6 @@ def test_mbstoi() -> None:
         dyn_range=60,
     )
 
-    assert mbstoi_val == pytest.approx(0.9061193314307591)
+    assert mbstoi_val == pytest.approx(
+        0.9061193314307591, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
diff --git a/tests/evaluator/mbstoi/test_mbstoi_utils.py b/tests/evaluator/mbstoi/test_mbstoi_utils.py
index daf782fbd..99ec01c78 100644
--- a/tests/evaluator/mbstoi/test_mbstoi_utils.py
+++ b/tests/evaluator/mbstoi/test_mbstoi_utils.py
@@ -63,8 +63,12 @@ def test_equalisation_cancellation() -> None:
     assert p_ec_m.shape == (n_gamma_bands, n_gammas)
 
     # check values
-    assert np.sum(intermediate_grid) == pytest.approx(277.84700307853785)
-    assert np.sum(p_ec_m) == pytest.approx(73.14293826967146)
+    assert np.sum(intermediate_grid) == pytest.approx(
+        277.84700307853785, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(p_ec_m) == pytest.approx(
+        73.14293826967146, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_firstpartfunc() -> None:
@@ -83,7 +87,9 @@ def test_firstpartfunc() -> None:
         epsexp=np.random.random(size=(1, n_gammas)),
     )
     assert result.shape == (n_taus, n_gammas)
-    assert np.sum(result) == pytest.approx(405590.0256254587)
+    assert np.sum(result) == pytest.approx(
+        405590.0256254587, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_secondpartfunc() -> None:
@@ -103,7 +109,9 @@ def test_secondpartfunc() -> None:
         gammas=np.random.random(size=(1, n_gammas)),
     )
     assert result.shape == (n_taus, n_gammas)
-    assert np.sum(result) == pytest.approx(127394.91897484378)
+    assert np.sum(result) == pytest.approx(
+        127394.91897484378, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_thirdpartfunc() -> None:
@@ -123,7 +131,9 @@ def test_thirdpartfunc() -> None:
         gammas=np.random.random(size=(1, n_gammas)),
     )
     assert result.shape == (n_taus, n_gammas)
-    assert np.sum(result) == pytest.approx(9483.482148264484)
+    assert np.sum(result) == pytest.approx(
+        9483.482148264484, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_fourthpartfunc() -> None:
@@ -141,7 +151,9 @@ def test_fourthpartfunc() -> None:
         deltexp=np.random.random(size=(1, n_taus)),
     )
     assert result.shape == (n_taus, n_gammas)
-    assert np.sum(result) == pytest.approx(75883.96658627654)
+    assert np.sum(result) == pytest.approx(
+        75883.96658627654, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_stft() -> None:
@@ -153,7 +165,9 @@ def test_stft() -> None:
     stft_out = stft(signal, win_size=128, fft_size=fft_size)
 
     assert stft_out.shape == (8, fft_size)
-    assert np.sum(stft_out) == pytest.approx(0.07977179832430759)
+    assert np.sum(stft_out) == pytest.approx(
+        0.07977179832430759, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_remove_silent_frames() -> None:
@@ -178,11 +192,21 @@ def test_remove_silent_frames() -> None:
         hop=32,
     )
 
-    assert np.sum(xl_sil[0:300]) == pytest.approx(0.0)
-    assert np.sum(xl_sil) == pytest.approx(128.15949932062742)
-    assert np.sum(xr_sil) == pytest.approx(272.06229083012374)
-    assert np.sum(yl_sil) == pytest.approx(413.65823132789836)
-    assert np.sum(yr_sil) == pytest.approx(551.1857227061379)
+    assert np.sum(xl_sil[0:300]) == pytest.approx(
+        0.0, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(xl_sil) == pytest.approx(
+        128.15949932062742, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(xr_sil) == pytest.approx(
+        272.06229083012374, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(yl_sil) == pytest.approx(
+        413.65823132789836, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert np.sum(yr_sil) == pytest.approx(
+        551.1857227061379, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_thirdoct() -> None:
@@ -195,15 +219,25 @@ def test_thirdoct() -> None:
         freq_high,
     ) = thirdoct(frequency_sampling=8000, nfft=512, num_bands=3, min_freq=100)
 
-    assert freq_low == pytest.approx([93.75, 109.375, 140.625])
-    assert freq_high == pytest.approx([109.375, 140.625, 171.875])
+    assert freq_low == pytest.approx(
+        [93.75, 109.375, 140.625], rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
+    assert freq_high == pytest.approx(
+        [109.375, 140.625, 171.875], rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
     assert centre_frequencies == pytest.approx(
-        np.array([[100.0, 125.99210499, 158.7401052]])
+        np.array([[100.0, 125.99210499, 158.7401052]]),
+        rel=pytest.rel_tolerance,
+        abs=pytest.abs_tolerance,
     )
     assert octave_band_matrix.shape == (3, 257)
-    assert np.sum(octave_band_matrix) == pytest.approx(5.0)
+    assert np.sum(octave_band_matrix) == pytest.approx(
+        5.0, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
     assert frequency_band_edges_indices == pytest.approx(
-        np.array([[7, 7], [8, 9], [10, 11]])
+        np.array([[7, 7], [8, 9], [10, 11]]),
+        rel=pytest.rel_tolerance,
+        abs=pytest.abs_tolerance,
     )
 
 
diff --git a/tests/evaluator/msbg/test_smearing.py b/tests/evaluator/msbg/test_smearing.py
index 4f20380ab..490d4d2ff 100644
--- a/tests/evaluator/msbg/test_smearing.py
+++ b/tests/evaluator/msbg/test_smearing.py
@@ -35,7 +35,9 @@ def test_smear_valid_input():
     input_signal = np.random.rand(10000)
     output_signal = Smearer(r_lower, r_upper, sample_freq).smear(input_signal)
     assert output_signal.shape == (10240,)
-    assert np.sum(np.abs(output_signal)) == pytest.approx(5066.986397433977)
+    assert np.sum(np.abs(output_signal)) == pytest.approx(
+        5066.986397433977, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 def test_make_smear_mat3_valid_input():
diff --git a/tests/recipes/cad1/task1/test_enhance.py b/tests/recipes/cad1/task1/test_enhance_task1.py
similarity index 100%
rename from tests/recipes/cad1/task1/test_enhance.py
rename to tests/recipes/cad1/task1/test_enhance_task1.py
diff --git a/tests/recipes/cad1/task1/test_evaluate.py b/tests/recipes/cad1/task1/test_evaluate.py
index d0bf9b48e..422a4ad04 100644
--- a/tests/recipes/cad1/task1/test_evaluate.py
+++ b/tests/recipes/cad1/task1/test_evaluate.py
@@ -169,7 +169,9 @@ def test_evaluate_song_listener(
     # Check the outputs
     # Combined score
     assert isinstance(combined_score, float)
-    assert combined_score == pytest.approx(0.144920571533222, rel=1e-7)
+    assert combined_score == pytest.approx(
+        0.144920571533222, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
     # Per instrument score
     assert isinstance(per_instrument_score, dict)
@@ -177,5 +179,7 @@ def test_evaluate_song_listener(
         assert instrument in per_instrument_score
         assert isinstance(per_instrument_score[instrument], float)
         assert per_instrument_score[instrument] == pytest.approx(
-            expected_results[instrument], rel=1e-7
+            expected_results[instrument],
+            rel=pytest.rel_tolerance,
+            abs=pytest.abs_tolerance,
         )
diff --git a/tests/recipes/cad1/task2/test_audio_manager.py b/tests/recipes/cad1/task2/test_audio_manager.py
index e78b4aa0f..05e7537d6 100644
--- a/tests/recipes/cad1/task2/test_audio_manager.py
+++ b/tests/recipes/cad1/task2/test_audio_manager.py
@@ -1,9 +1,9 @@
 """Test for AudioManager module"""
 # pylint: disable=import-error
-
 from pathlib import Path
 
 import numpy as np
+import pytest
 from scipy.io import wavfile
 
 from recipes.cad1.task2.baseline.audio_manager import AudioManager
@@ -30,4 +30,6 @@ def test_save_audios(tmp_path):
 
     # Check if audio data was saved correctly
     sample_rate, _ = wavfile.read(audio_file)
-    assert sample_rate == audio_manager.sample_rate
+    assert sample_rate == pytest.approx(
+        audio_manager.sample_rate, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
diff --git a/tests/recipes/cad1/task2/test_enhance.py b/tests/recipes/cad1/task2/test_enhance_task2.py
similarity index 100%
rename from tests/recipes/cad1/task2/test_enhance.py
rename to tests/recipes/cad1/task2/test_enhance_task2.py
diff --git a/tests/recipes/cpc2/__init__.py b/tests/recipes/cpc2/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tests/recipes/cpc2/test_evaluate.py b/tests/recipes/cpc2/test_evaluate_cpc2.py
similarity index 88%
rename from tests/recipes/cpc2/test_evaluate.py
rename to tests/recipes/cpc2/test_evaluate_cpc2.py
index dc31d2765..cb6414ec2 100644
--- a/tests/recipes/cpc2/test_evaluate.py
+++ b/tests/recipes/cpc2/test_evaluate_cpc2.py
@@ -19,7 +19,9 @@
 )
 def test_rmse_score_ok(x, y, expected):
     """Test the function rmse_score valid inputs"""
-    assert rmse_score(np.array(x), np.array(y)) == pytest.approx(expected)
+    assert rmse_score(np.array(x), np.array(y)) == pytest.approx(
+        expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 @pytest.mark.parametrize(
@@ -38,7 +40,9 @@ def test_rmse_score_error(x, y, expected):
 )
 def test_ncc_score_ok(x, y, expected):
     """Test the function ncc_score valid inputs"""
-    assert ncc_score(np.array(x), np.array(y)) == pytest.approx(expected)
+    assert ncc_score(np.array(x), np.array(y)) == pytest.approx(
+        expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 @pytest.mark.parametrize(
@@ -56,7 +60,9 @@ def test_ncc_score_error(x, y, expected):
 )
 def test_kt_score_ok(x, y, expected):
     """Test the function kt_score valid inputs"""
-    assert kt_score(np.array(x), np.array(y)) == pytest.approx(expected)
+    assert kt_score(np.array(x), np.array(y)) == pytest.approx(
+        expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 @pytest.mark.parametrize(
@@ -82,7 +88,9 @@ def test_kt_score_error(x, y, expected):
 )
 def test_std_err_ok(x, y, expected):
     """Test the function std_err valid inputs"""
-    assert std_err(np.array(x), np.array(y)) == pytest.approx(expected)
+    assert std_err(np.array(x), np.array(y)) == pytest.approx(
+        expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )
 
 
 @pytest.mark.parametrize(
diff --git a/tests/recipes/cpc2/test_predict.py b/tests/recipes/cpc2/test_predict.py
index a98ba9756..9c840e72c 100644
--- a/tests/recipes/cpc2/test_predict.py
+++ b/tests/recipes/cpc2/test_predict.py
@@ -24,7 +24,7 @@ def test_logistic_model_symmetry(model: LogisticModel, value):
     """Test the LogisticModel is symmetric."""
     symmetric_value = 4 - value
     assert model.predict(value) + model.predict(symmetric_value) == pytest.approx(
-        100.0, abs=1e-3
+        100.0, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
     )
 
 
@@ -38,9 +38,13 @@ def test_logistic_model_extremes(model, value):
     """Test the LogisticModel class ."""
     # logistic_model must asymptote to 0 and 100 for extreme values
     if value > 10:
-        assert model.predict(value) == pytest.approx(100)
+        assert model.predict(value) == pytest.approx(
+            100, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+        )
     elif value < -10:
-        assert model.predict(value) == pytest.approx(0)
+        assert model.predict(value) == pytest.approx(
+            0, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+        )
 
 
 @pytest.mark.parametrize(
@@ -68,4 +72,6 @@ def test_make_disjoint_train_set_empty(data_1, data_2, expected):
     test_df1 = pd.DataFrame([data_1])
     test_df2 = pd.DataFrame([data_2])
     disjoint = make_disjoint_train_set(test_df1, test_df2)
-    assert disjoint.shape[0] == expected
+    assert disjoint.shape[0] == pytest.approx(
+        expected, rel=pytest.rel_tolerance, abs=pytest.abs_tolerance
+    )