Skip to content

Commit

Permalink
Reduce test tolerance from 3 to 1 dB
Browse files Browse the repository at this point in the history
  • Loading branch information
ansaminard committed Dec 13, 2024
1 parent ddaf9a2 commit e2d9423
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -478,24 +478,24 @@ def test_source_harmonics_two_parameters_get_output(dpf_sound_test_server):
delat_f = psd_freq[1] - psd_freq[0]

# Check the sound power level in the octave bands centered at 500, 1000 and 2000 Hz.
# Due to the non-deterministic nature of the produced signal, tolerance is set to 3 dB.
# Due to the non-deterministic nature of the produced signal, tolerance is set to 1 dB.
psd_squared_band = psd_squared[
(psd_freq >= 500 * 2 ** (-1 / 2)) & (psd_freq < 500 * 2 ** (1 / 2))
]
level = 10 * np.log10(psd_squared_band.sum() * delat_f / REF_ACOUSTIC_POWER)
assert level == pytest.approx(EXP_LEVEL_OCTAVE_BAND_500, abs=3.0)
assert level == pytest.approx(EXP_LEVEL_OCTAVE_BAND_500, abs=1.0)

psd_squared_band = psd_squared[
(psd_freq >= 1000 * 2 ** (-1 / 2)) & (psd_freq < 1000 * 2 ** (1 / 2))
]
level = 10 * np.log10(psd_squared_band.sum() * delat_f / REF_ACOUSTIC_POWER)
assert level == pytest.approx(EXP_LEVEL_OCTAVE_BAND_1000, abs=3.0)
assert level == pytest.approx(EXP_LEVEL_OCTAVE_BAND_1000, abs=1.0)

psd_squared_band = psd_squared[
(psd_freq >= 2000 * 2 ** (-1 / 2)) & (psd_freq < 2000 * 2 ** (1 / 2))
]
level = 10 * np.log10(psd_squared_band.sum() * delat_f / REF_ACOUSTIC_POWER)
assert level == pytest.approx(EXP_LEVEL_OCTAVE_BAND_2000, abs=3.0)
assert level == pytest.approx(EXP_LEVEL_OCTAVE_BAND_2000, abs=1.0)

# Test output with another source file with inverted controls.
source_obj.load_source_harmonics_two_parameters(
Expand All @@ -520,24 +520,24 @@ def test_source_harmonics_two_parameters_get_output(dpf_sound_test_server):
delat_f = psd_freq[1] - psd_freq[0]

# Check the sound power level in the octave bands centered at 500, 1000 and 2000 Hz.
# Due to the non-deterministic nature of the produced signal, tolerance is set to 3 dB.
# Due to the non-deterministic nature of the produced signal, tolerance is set to 1 dB.
psd_squared_band = psd_squared[
(psd_freq >= 500 * 2 ** (-1 / 2)) & (psd_freq < 500 * 2 ** (1 / 2))
]
level = 10 * np.log10(psd_squared_band.sum() * delat_f / REF_ACOUSTIC_POWER)
assert level == pytest.approx(EXP_LEVEL_OCTAVE_BAND_500_INVCON, abs=3.0)
assert level == pytest.approx(EXP_LEVEL_OCTAVE_BAND_500_INVCON, abs=1.0)

psd_squared_band = psd_squared[
(psd_freq >= 1000 * 2 ** (-1 / 2)) & (psd_freq < 1000 * 2 ** (1 / 2))
]
level = 10 * np.log10(psd_squared_band.sum() * delat_f / REF_ACOUSTIC_POWER)
assert level == pytest.approx(EXP_LEVEL_OCTAVE_BAND_1000_INVCON, abs=3.0)
assert level == pytest.approx(EXP_LEVEL_OCTAVE_BAND_1000_INVCON, abs=1.0)

psd_squared_band = psd_squared[
(psd_freq >= 2000 * 2 ** (-1 / 2)) & (psd_freq < 2000 * 2 ** (1 / 2))
]
level = 10 * np.log10(psd_squared_band.sum() * delat_f / REF_ACOUSTIC_POWER)
assert level == pytest.approx(EXP_LEVEL_OCTAVE_BAND_2000_INVCON, abs=3.0)
assert level == pytest.approx(EXP_LEVEL_OCTAVE_BAND_2000_INVCON, abs=1.0)


def test_source_harmonics_two_parameters_get_output_unprocessed(dpf_sound_test_server):
Expand Down

0 comments on commit e2d9423

Please sign in to comment.