Changeset c09efca
- Timestamp:
- May 13, 2016, 5:58:02 PM (9 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 1167631
- Parents:
- 1164fd85
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_cvec.py
r1164fd85 rc09efca 5 5 from aubio import cvec, fvec, float_type 6 6 import numpy as np 7 8 wrong_type = 'float32' if float_type == 'float64' else 'float64' 7 9 8 10 class aubio_cvec_test_case(TestCase): … … 50 52 """ check dest cvec is still reachable after source was deleted """ 51 53 spec = cvec(1024) 52 a = np.random.rand(1024/ 2+1).astype(float_type)53 b = np.random.rand(1024/ 2+1).astype(float_type)54 a = np.random.rand(1024//2+1).astype(float_type) 55 b = np.random.rand(1024//2+1).astype(float_type) 54 56 spec.norm = a 55 57 spec.phas = b … … 103 105 a.phas = b 104 106 107 def test_cvec_repr(self): 108 win_s = 512 109 c = cvec(win_s) 110 expected_repr = "aubio cvec of {:d} elements".format(win_s//2+1) 111 self.assertEqual(repr(c), expected_repr) 112 113 class aubio_cvec_wrong_norm_input(TestCase): 114 115 def test_wrong_length(self): 116 with self.assertRaises(ValueError): 117 cvec(-1) 118 119 def test_set_norm_with_scalar(self): 120 a = cvec(512) 121 with self.assertRaises(ValueError): 122 a.norm = 1 123 124 def test_set_norm_with_scalar_array(self): 125 a = cvec(512) 126 with self.assertRaises(ValueError): 127 a.norm = np.ndarray(1, dtype = 'int') 128 129 def test_set_norm_with_int_array(self): 130 a = cvec(512) 131 with self.assertRaises(ValueError): 132 a.norm = np.zeros(512//2+1, dtype = 'int') 133 134 def test_set_norm_with_wrong_float_array(self): 135 a = cvec(512) 136 with self.assertRaises(ValueError): 137 a.norm = np.zeros(512//2+1, dtype = wrong_type) 138 139 def test_set_norm_with_wrong_2d_array(self): 140 a = cvec(512) 141 with self.assertRaises(ValueError): 142 a.norm = np.zeros((512//2+1, 2), dtype = float_type) 143 105 144 if __name__ == '__main__': 106 145 from nose2 import main
Note: See TracChangeset
for help on using the changeset viewer.