Skip to content

Commit

Permalink
Fixes tests numerical accuracy and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fakufaku committed Dec 31, 2024
1 parent cf35908 commit 35fdb3f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
class TestSourceDirectivity(TestCase):
def test_zero_gain(self):
gain = np.amax(room.rir[0][0])
self.assertTrue(gain < (10**-10))
self.assertTrue(gain < 1e-7)


def get_error():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,9 @@ def test_source_directions_nonshoebox():
images_expected_reordered = images_expected[order_expected, :]
directions_expected_reordered = directions_expected[order_expected, :]

np.testing.assert_almost_equal(images_obtained, images_expected_reordered)
np.testing.assert_almost_equal(directions_obtained, directions_expected_reordered)
np.testing.assert_almost_equal(
images_obtained, images_expected_reordered, decimal=5
)
np.testing.assert_almost_equal(
directions_obtained, directions_expected_reordered, decimal=5
)
2 changes: 1 addition & 1 deletion pyroomacoustics/random/tests/test_rejection.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
hist.push(points)
hist.plot()

"""
r"""
ax.scatter(X, Y, Z, s=50)
ax.plot(
*np.stack((torch.zeros_like(loc), loc)).T,
Expand Down
2 changes: 1 addition & 1 deletion pyroomacoustics/random/tests/test_spherical.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_stat_prop_power_spherical():
X, Y, Z = pra.random.power_spherical(loc=loc, scale=scale, size=1000).T

ax.scatter(X, Y, Z, s=50)
"""
r"""
ax.plot(
*np.stack((torch.zeros_like(loc), loc)).T,
linewidth=4,
Expand Down
4 changes: 3 additions & 1 deletion pyroomacoustics/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,9 @@ def image_source_model(self):
self.visibility.append(np.zeros((self.mic_array.M, 1), dtype=np.int32))
# We also need a fake array of directions as this is expected later in
# the code.
source.directions = np.zeros((self.mic_array.M, self.dim, 1), dtype=np.float32)
source.directions = np.zeros(
(self.mic_array.M, self.dim, 1), dtype=np.float32
)

# Update the state
self.simulator_state["ism_done"] = True
Expand Down

0 comments on commit 35fdb3f

Please sign in to comment.