Skip to content

Commit 35fdb3f

Browse files
committed
Fixes tests numerical accuracy and warnings
1 parent cf35908 commit 35fdb3f

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

Diff for: pyroomacoustics/directivities/tests/test_source_directivities.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
class TestSourceDirectivity(TestCase):
3131
def test_zero_gain(self):
3232
gain = np.amax(room.rir[0][0])
33-
self.assertTrue(gain < (10**-10))
33+
self.assertTrue(gain < 1e-7)
3434

3535

3636
def get_error():

Diff for: pyroomacoustics/directivities/tests/test_source_directivities_nonshoebox.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,9 @@ def test_source_directions_nonshoebox():
6969
images_expected_reordered = images_expected[order_expected, :]
7070
directions_expected_reordered = directions_expected[order_expected, :]
7171

72-
np.testing.assert_almost_equal(images_obtained, images_expected_reordered)
73-
np.testing.assert_almost_equal(directions_obtained, directions_expected_reordered)
72+
np.testing.assert_almost_equal(
73+
images_obtained, images_expected_reordered, decimal=5
74+
)
75+
np.testing.assert_almost_equal(
76+
directions_obtained, directions_expected_reordered, decimal=5
77+
)

Diff for: pyroomacoustics/random/tests/test_rejection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
hist.push(points)
3737
hist.plot()
3838

39-
"""
39+
r"""
4040
ax.scatter(X, Y, Z, s=50)
4141
ax.plot(
4242
*np.stack((torch.zeros_like(loc), loc)).T,

Diff for: pyroomacoustics/random/tests/test_spherical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_stat_prop_power_spherical():
3434
X, Y, Z = pra.random.power_spherical(loc=loc, scale=scale, size=1000).T
3535

3636
ax.scatter(X, Y, Z, s=50)
37-
"""
37+
r"""
3838
ax.plot(
3939
*np.stack((torch.zeros_like(loc), loc)).T,
4040
linewidth=4,

Diff for: pyroomacoustics/room.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,9 @@ def image_source_model(self):
22372237
self.visibility.append(np.zeros((self.mic_array.M, 1), dtype=np.int32))
22382238
# We also need a fake array of directions as this is expected later in
22392239
# the code.
2240-
source.directions = np.zeros((self.mic_array.M, self.dim, 1), dtype=np.float32)
2240+
source.directions = np.zeros(
2241+
(self.mic_array.M, self.dim, 1), dtype=np.float32
2242+
)
22412243

22422244
# Update the state
22432245
self.simulator_state["ism_done"] = True

0 commit comments

Comments
 (0)