Skip to content

Commit

Permalink
Fix incorrect dimension test in previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mcclure committed Oct 4, 2023
1 parent 493d429 commit 7edf7f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion _soundfile_data
4 changes: 2 additions & 2 deletions soundfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,8 +1332,8 @@ def _check_dtype(self, dtype):

def _array_io(self, action, array, frames):
"""Check array and call low-level IO function."""
if self.channels not in (1,2):
raise ValueError("Cannot convert: file has {0} channels, but only 1 or 2 is supported".format(self.channels))
if array.ndim not in (1,2):
raise ValueError("Invalid shape: {0!r} ({1})".format(array.shape, "0 dimensions not supported" if array.ndim < 1 else "too many dimensions"))
array_channels = 1 if array.ndim == 1 else array.shape[1]
if array_channels != self.channels:
raise ValueError("Invalid shape: {0!r} (Expected {1} channels, got {2})".format(array.shape, self.channels, array_channels))
Expand Down

0 comments on commit 7edf7f3

Please sign in to comment.