Skip to content

Commit

Permalink
Fix bug whereby multiplication by WindowingFunc didn't maintain origi…
Browse files Browse the repository at this point in the history
…nal dtype
  • Loading branch information
JohnVinyard committed May 31, 2018
1 parent ea8470c commit 681513c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion zounds/spectral/sliding_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __mul__(self, other):
wdata = self._wdata(size)
if wdata is None:
return other
return wdata * other
return (wdata * other).astype(other.dtype)

def __rmul__(self, other):
return self.__mul__(other)
Expand Down
6 changes: 6 additions & 0 deletions zounds/spectral/test_sliding_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def test_multiply_1d(self):
result = wf * samples
self.assertEqual(samples.shape, result.shape)

def test_maintains_dtype(self):
samples = np.random.random_sample(10).astype(np.float32)
wf = OggVorbisWindowingFunc()
result = wf * samples
self.assertEqual(np.float32, result.dtype)


class SlidingWindowTests(unittest2.TestCase):
def _check(self, samplerate, expected_window_size, expected_step_size):
Expand Down

0 comments on commit 681513c

Please sign in to comment.