def test_can_apply_windowed_to_integer_dtype(self): samples = np.zeros(44100).astype(np.int64) l, w = windowed(samples, 8192, 4096) self.assertEqual(w.dtype, np.int64) self.assertEqual(8192, w.shape[1])
def test_can_apply_windowed_twice(self): a = np.arange(100) _, w = windowed(a, 7, 3) _, w2 = windowed(w, 3, 1) self.assertEqual((3, 7), w2.shape[1:])
def test_can_apply_windowed_twice_2(self): samples = np.random.random_sample(44100) _, w = windowed(samples, 512, 256) f = np.fft.fft(w)[:, 1:] _, w2 = windowed(f, 3, 1) self.assertEqual((3, 511), w2.shape[1:])
def test_twod_pad(self): a = np.arange(20).reshape((10, 2)) l, w = windowed(a, 3, 2, dopad=True) self.assertEqual(0, l.shape[0]) self.assertEqual((5, 3, 2), w.shape)
def test_no_stepsize_specified(self): a = np.arange(10) l, w = windowed(a, 2) self.assertEqual(0, l.shape[0]) self.assertEqual((5, 2), w.shape)
def test_windowsize_gt_length_pad(self): a = np.arange(5) l, w = windowed(a, 6, 1, dopad=True) self.assertEqual(0, l.shape[0]) self.assertEqual((1, 6), w.shape)
def test_twod_cut(self): a = np.arange(20).reshape((10, 2)) l, w = windowed(a, 3, 2) self.assertEqual(2, l.shape[0]) self.assertEqual((4, 3, 2), w.shape)
def test_windowsize_three_stepsize_three_pad(self): a = np.arange(10) l, w = windowed(a, 3, 3, dopad=True) self.assertEqual(0, l.shape[0]) self.assertEqual((4, 3), w.shape)
def test_windowsize_gt_length_cut(self): a = np.arange(5) l, w = windowed(a, 6, 1) self.assertEqual(5, l.shape[0]) self.assertEqual(0, w.shape[0])
def test_windowsize_three_stepsize_two_pad(self): a = np.arange(10) l, w = windowed(a, 3, 2, dopad=True) self.assertEqual(0, l.shape[0]) self.assertEqual((5, 3), w.shape) self.assertTrue(np.all([0, 0] == w[-1, -1]))
def test_windowsize_three_stepsize_three_cut(self): a = np.arange(10) l, w = windowed(a, 3, 3) self.assertEqual(1, l.shape[0]) self.assertEqual((3, 3), w.shape)
def test_windowsize_two_stepsize_two_pad(self): a = np.arange(10) l, w = windowed(a, 2, 2, True) self.assertEqual(0, l.shape[0]) self.assertEqual((5, 2), w.shape)
def test_windowsize_two_stepsize_one_cut(self): a = np.arange(10) l, w = windowed(a, 2, 1) self.assertEqual(1, l.shape[0]) self.assertEqual((9, 2), w.shape)
def test_drop_samples(self): a = np.arange(10) l, w = windowed(a, 1, 2) self.assertEqual(5, w.shape[0]) self.assertEqual(0, l.shape[0])
def test_no_windowing(self): a = np.arange(10) l, w = windowed(a, 1, 1) self.assertTrue(a is w) self.assertEqual(0, l.shape[0])
def test_stepsize_ltone(self): a = np.arange(10) self.assertRaises(ValueError, lambda: windowed(a, 1, 0))