Skip to content

Commit 631378d

Browse files
committed
Fix dimension check in Stream.write()
1 parent 3c4ffbd commit 631378d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sounddevice.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,8 +1524,12 @@ def write(self, data):
15241524
data = np.asarray(data)
15251525
_, dtype = _split(self._dtype)
15261526
_, channels = _split(self._channels)
1527-
if data.ndim > 1 and data.shape[1] != channels:
1528-
raise ValueError('Number of channels must match')
1527+
if data.ndim < 2:
1528+
data = data.reshape(-1, 1)
1529+
elif data.ndim > 2:
1530+
raise ValueError('data must be one- or two-dimensional')
1531+
if data.shape[1] != channels:
1532+
raise ValueError('number of channels must match')
15291533
if data.dtype != dtype:
15301534
raise TypeError('dtype mismatch: {!r} vs {!r}'.format(
15311535
data.dtype.name, dtype))

0 commit comments

Comments
 (0)