Skip to content

Commit ed3b9c2

Browse files
author
Bastian Bechtold
committed
Merge branch 'mcclure-channel-error'
2 parents 6195420 + 0812810 commit ed3b9c2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

soundfile.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,10 +1379,11 @@ def _check_dtype(self, dtype):
13791379

13801380
def _array_io(self, action, array, frames):
13811381
"""Check array and call low-level IO function."""
1382-
if (array.ndim not in (1, 2) or
1383-
array.ndim == 1 and self.channels != 1 or
1384-
array.ndim == 2 and array.shape[1] != self.channels):
1385-
raise ValueError("Invalid shape: {0!r}".format(array.shape))
1382+
if array.ndim not in (1,2):
1383+
raise ValueError("Invalid shape: {0!r} ({1})".format(array.shape, "0 dimensions not supported" if array.ndim < 1 else "too many dimensions"))
1384+
array_channels = 1 if array.ndim == 1 else array.shape[1]
1385+
if array_channels != self.channels:
1386+
raise ValueError("Invalid shape: {0!r} (Expected {1} channels, got {2})".format(array.shape, self.channels, array_channels))
13861387
if not array.flags.c_contiguous:
13871388
raise ValueError("Data must be C-contiguous")
13881389
ctype = self._check_dtype(array.dtype.name)

0 commit comments

Comments
 (0)