iver56 / audiomentations

A Python library for audio data augmentation. Inspired by albumentations. Useful for machine learning.
https://iver56.github.io/audiomentations/
MIT License
1.76k stars 183 forks source link

test_simulate_apply_parity - AssertionError: approx() is not supported in a boolean context #321

Closed atamazian closed 4 months ago

atamazian commented 4 months ago

When running pytest on the latest version, I'm getting new error in TestRoomSimulatorTransform:

__________________________________________________ TestRoomSimulatorTransform.test_simulate_apply_parity __________________________________________________

self = <tests.test_room_simulator.TestRoomSimulatorTransform object at 0x0000028E5881BF40>

    def test_simulate_apply_parity(self):
        """
        Tests whether RoomSimulator.apply gives the same result as Roomsimulator.room.simulate() in the 1D case.

        This mainly tests that we took into consideration and compensated about the delays introduced when pyroomacoustics
        computes the room impulse response.

        See:[Create the Room Impulse Response](https://pyroomacoustics.readthedocs.io/en/pypi-release/pyroomacoustics.room.html?highlight=simulate#)
        """

        random.seed(1)
        sample_rate = 16000
        samples = get_sinc_impulse(sample_rate, 10)

        augment = RoomSimulator()
        augmented_samples_apply = augment(samples=samples, sample_rate=sample_rate)
        augment.room.simulate()
        augmented_samples_simulate = augment.room.mic_array.signals.astype(
            np.float32
        ).flatten()

>       assert pytest.approx(
            augmented_samples_apply, augmented_samples_simulate, abs=1e-15
        )
E       AssertionError: approx() is not supported in a boolean context.
E       Did you mean: `assert a == approx(b)`?

tests\test_room_simulator.py:43: AssertionError

Can you check this out?

iver56 commented 4 months ago

Sorry, my bad. I'll fix it.

iver56 commented 4 months ago

https://github.com/iver56/audiomentations/commit/5439a684d32801d6fa0d7415cb4db8a7fa1e2960

atamazian commented 4 months ago

Sorry for bothering again, but I'm getting

FAILED tests/test_room_simulator.py::TestRoomSimulatorTransform::test_simulate_apply_parity - assert array([-2.212...dtype=float32) == approx([-2.21...10 ± 1.0e-15])
iver56 commented 4 months ago

Does it pass if you set the tolerance to 1.0e-9 instead of 1.0e-15?

atamazian commented 4 months ago

Yes, it does.

iver56 commented 4 months ago

How about this: https://github.com/iver56/audiomentations/commit/3894cc41cc6496a1b9ae54613cf7dd2343c80849

atamazian commented 4 months ago

It's OK now.