History

python/tests/test_fvec_shift.py: add tests for shift() and ishift()

Paul Brossier committed 8 years ago

Commit 87e181d1 parent b5322751 file · +35 −0Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/tests/test_fvec_shift.py+35−0
@@ -0,0 +1,35 @@
1+#! /usr/bin/env python
2+
3+import numpy as np
4+from numpy.testing import TestCase, assert_equal
5+import aubio
6+
7+class aubio_shift_test_case(TestCase):
8+
9+ def run_shift_ishift(self, n):
10+ ramp = np.arange(n, dtype=aubio.float_type)
11+ # construct expected output
12+ # even length: [5. 6. 7. 8. 9. 0. 1. 2. 3. 4.]
13+ # odd length: [4. 5. 6. 0. 1. 2. 3.]
14+ half = n - n//2
15+ expected = np.concatenate([np.arange(half, n), np.arange(half)])
16+ # shift in place, returns modified copy
17+ assert_equal(aubio.shift(ramp), expected)
18+ # check input was changed as expected
19+ assert_equal(ramp, expected)
20+ # construct expected output
21+ expected = np.arange(n)
22+ # revert shift in place, returns modifed copy
23+ assert_equal(aubio.ishift(ramp), expected)
24+ # check input was shifted back
25+ assert_equal(ramp, expected)
26+
27+ def test_can_shift_fvec(self):
28+ self.run_shift_ishift(10)
29+
30+ def test_can_shift_fvec_odd(self):
31+ self.run_shift_ishift(7)
32+
33+from unittest import main
34+if __name__ == '__main__':
35+ main()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t