Changeset f264b17 for python/tests/test_mathutils.py
- Timestamp:
- Jun 22, 2016, 1:00:10 PM (8 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:
- 4b9443c4
- Parents:
- 60fc05b (diff), 6769586 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_mathutils.py
r60fc05b rf264b17 1 1 #! /usr/bin/env python 2 2 3 from unittest import main 3 4 from numpy.testing import TestCase, assert_equal 4 5 from numpy import array, arange, isnan, isinf … … 13 14 unwrap2pi(int(23)) 14 15 unwrap2pi(float(23.)) 15 unwrap2pi( long(23.))16 unwrap2pi(int(23.)) 16 17 unwrap2pi(arange(10)) 17 18 unwrap2pi(arange(10).astype("int")) … … 24 25 unwrap2pi(a) 25 26 a = pi/100. * arange(-600,600).astype("float") 26 b = unwrap2pi(a)27 unwrap2pi(a) 27 28 #print zip(a, b) 28 29 29 try: 30 print unwrap2pi(["23.","24.",25.]) 31 except Exception, e: 32 pass 30 def test_unwrap2pi_fails_on_list(self): 31 with self.assertRaises((TypeError, NotImplementedError)): 32 unwrap2pi(["23.","24.",25.]) 33 33 34 34 def test_unwrap2pi_takes_fvec(self): … … 54 54 55 55 def test_freqtomidi(self): 56 a = array( range(-20, 50000, 100) + [ -1e32, 1e32 ])56 a = array(list(range(-20, 50000, 100)) + [ -1e32, 1e32 ]) 57 57 b = freqtomidi(a) 58 58 #print zip(a, b) … … 62 62 63 63 def test_miditofreq(self): 64 a = range(-30, 200) + [-100000, 10000]64 a = list(range(-30, 200)) + [-100000, 10000] 65 65 b = miditofreq(a) 66 66 #print zip(a, b) … … 70 70 71 71 def test_miditobin(self): 72 a = range(-30, 200) + [-100000, 10000]73 b = [ bintomidi(x, 44100, 512) for x in a ]72 a = list(range(-30, 200)) + [-100000, 10000] 73 b = [ miditobin(x, 44100, 512) for x in a ] 74 74 #print zip(a, b) 75 75 assert_equal ( isnan(array(b)), False ) … … 78 78 79 79 def test_bintomidi(self): 80 a = range(-100, 512)80 a = list(range(-100, 512)) 81 81 b = [ bintomidi(x, 44100, 512) for x in a ] 82 82 #print zip(a, b) … … 86 86 87 87 def test_freqtobin(self): 88 a = range(-20, 50000, 100) + [ -1e32, 1e32 ]88 a = list(range(-20, 50000, 100)) + [ -1e32, 1e32 ] 89 89 b = [ freqtobin(x, 44100, 512) for x in a ] 90 90 #print zip(a, b) … … 94 94 95 95 def test_bintofreq(self): 96 a = range(-20, 148)96 a = list(range(-20, 148)) 97 97 b = [ bintofreq(x, 44100, 512) for x in a ] 98 98 #print zip(a, b) … … 102 102 103 103 if __name__ == '__main__': 104 from unittest import main105 104 main()
Note: See TracChangeset
for help on using the changeset viewer.