Skip to content

Commit 79db2b1

Browse files
committed
Fixes BSS algorithm for new API of numpy.linalg.solve in numpy 2.0
1 parent 449f725 commit 79db2b1

File tree

6 files changed

+9
-7
lines changed

6 files changed

+9
-7
lines changed

CHANGELOG.rst

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Bugfix
2626
ticks when called with ``kind="tf"``
2727
- Fixes an issue where the ``visibility`` attribute of the room is not
2828
set if there are no visible source or image source in the room. (#313)
29+
- Fixes issue with cast reflections delays to float32 in room.py (#353)
30+
- Fixes calls to ``numpy.linalg.solve`` with Numpy 2.0 API
2931

3032
`0.7.4`_ - 2024-04-25
3133
---------------------

pyroomacoustics/bss/auxiva.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def demix(Y, X, W):
227227
)
228228

229229
WV = np.matmul(W_hat, V)
230-
W[:, s, :] = np.conj(np.linalg.solve(WV, eyes[:, :, s]))
230+
W[:, s, :] = np.conj(np.linalg.solve(WV, eyes[:, :, [s]]))[..., 0]
231231

232232
# normalize
233233
denom = np.matmul(

pyroomacoustics/bss/fastmnmf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ def separate():
175175

176176
try:
177177
tmp_FM = np.linalg.solve(
178-
np.matmul(Q_FMM, V_FMM), np.eye(n_chan)[None, m]
179-
)
178+
np.matmul(Q_FMM, V_FMM), np.eye(n_chan)[None, :, [m]]
179+
)[..., 0]
180180
except np.linalg.LinAlgError:
181181
# If Gaussian elimination fails due to a singlular matrix, we
182182
# switch to the pseudo-inverse solution

pyroomacoustics/bss/fastmnmf2.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ def separate():
165165
np.einsum("ftij, ft -> fij", XX_FTMM, 1 / Y_FTM[..., m]) / n_frames
166166
)
167167
tmp_FM = np.linalg.solve(
168-
np.matmul(Q_FMM, V_FMM), np.eye(n_chan)[None, m]
169-
)
168+
np.matmul(Q_FMM, V_FMM), np.eye(n_chan)[None, :, [m]]
169+
)[..., 0]
170170
Q_FMM[:, m] = (
171171
tmp_FM
172172
/ np.sqrt(

pyroomacoustics/bss/ilrma.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def demix(Y, X, W):
159159
C = np.matmul((X * iR[s, :, None, :]), np.conj(X.swapaxes(1, 2))) / n_frames
160160

161161
WV = np.matmul(W, C)
162-
W[:, s, :] = np.conj(np.linalg.solve(WV, eyes[:, :, s]))
162+
W[:, s, :] = np.conj(np.linalg.solve(WV, eyes[:, :, [s]]))[..., 0]
163163

164164
# normalize
165165
denom = np.matmul(

pyroomacoustics/bss/sparseauxiva.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def demixsparse(Y, X, S, W):
148148
W_H = np.conj(np.swapaxes(W, 1, 2))
149149
WV = np.matmul(W_H, V[:, s, :, :])
150150
rhs = I[None, :, s][[0] * WV.shape[0], :]
151-
W[:, :, s] = np.linalg.solve(WV, rhs)
151+
W[:, :, s] = np.linalg.solve(WV, rhs[..., None])[..., 0]
152152

153153
# normalize
154154
P1 = np.conj(W[:, :, s])

0 commit comments

Comments
 (0)