Changeset 689106e for python/tests


Ignore:
Timestamp:
Apr 18, 2016, 11:24:47 PM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
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:
6db7600
Parents:
1c6fe64
Message:

python/tests/: prepare for python3 (see #33)

Location:
python/tests
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_fvec.py

    r1c6fe64 r689106e  
    2020        assert a.dtype == 'float32'
    2121        assert a.shape == (4,)
    22         assert_equal (range(4), a)
     22        assert_equal (list(range(4)), a)
    2323
    2424    def test_vector_assign_element(self):
     
    4242        a.T
    4343        array(a).T
    44         a = range(len(a))
     44        a = list(range(len(a)))
    4545
    4646    def test_wrong_values(self):
     
    5353    def test_alpha_norm_of_fvec(self):
    5454        a = fvec(2)
    55         self.assertEquals (alpha_norm(a, 1), 0)
     55        self.assertEqual (alpha_norm(a, 1), 0)
    5656        a[0] = 1
    57         self.assertEquals (alpha_norm(a, 1), 0.5)
     57        self.assertEqual (alpha_norm(a, 1), 0.5)
    5858        a[1] = 1
    59         self.assertEquals (alpha_norm(a, 1), 1)
     59        self.assertEqual (alpha_norm(a, 1), 1)
    6060        a = array([0, 1], dtype='float32')
    6161        from math import sqrt
     
    7474        # check 1d array
    7575        a = array(range(10), dtype = 'float32')
    76         self.assertEquals (alpha_norm(a, 1), 4.5)
     76        self.assertEqual (alpha_norm(a, 1), 4.5)
    7777
    7878    def test_alpha_norm_of_array_of_int(self):
     
    9292        assert_almost_equal (zero_crossing_rate(a), 1./3. )
    9393        a = array([0.]*100, dtype='float32')
    94         self.assertEquals (zero_crossing_rate(a), 0 )
     94        self.assertEqual (zero_crossing_rate(a), 0 )
    9595        a = array([-1.]*100, dtype='float32')
    96         self.assertEquals (zero_crossing_rate(a), 0 )
     96        self.assertEqual (zero_crossing_rate(a), 0 )
    9797        a = array([1.]*100, dtype='float32')
    98         self.assertEquals (zero_crossing_rate(a), 0 )
     98        self.assertEqual (zero_crossing_rate(a), 0 )
    9999
    100100    def test_alpha_norm_of_array_of_float64(self):
     
    106106        self.assertRaises (ValueError, alpha_norm, a, 1)
    107107        # check float64 1d array fail
    108         a = array(range(10), dtype = 'float64')
     108        a = array(list(range(10)), dtype = 'float64')
    109109        self.assertRaises (ValueError, alpha_norm, a, 1)
    110110        # check float64 2d array fail
    111         a = array([range(10), range(10)], dtype = 'float64')
     111        a = array([list(range(10)), list(range(10))], dtype = 'float64')
    112112        self.assertRaises (ValueError, alpha_norm, a, 1)
    113113
  • python/tests/test_mathutils.py

    r1c6fe64 r689106e  
    1313        unwrap2pi(int(23))
    1414        unwrap2pi(float(23.))
    15         unwrap2pi(long(23.))
     15        unwrap2pi(int(23.))
    1616        unwrap2pi(arange(10))
    1717        unwrap2pi(arange(10).astype("int"))
     
    2828
    2929        try:
    30             print unwrap2pi(["23.","24.",25.])
    31         except Exception, e:
     30            print (unwrap2pi(["23.","24.",25.]))
     31        except Exception as e:
    3232            pass
    3333
     
    5454
    5555    def test_freqtomidi(self):
    56         a = array(range(-20, 50000, 100) + [ -1e32, 1e32 ])
     56        a = array(list(range(-20, 50000, 100)) + [ -1e32, 1e32 ])
    5757        b = freqtomidi(a)
    5858        #print zip(a, b)
     
    6262
    6363    def test_miditofreq(self):
    64         a = range(-30, 200) + [-100000, 10000]
     64        a = list(range(-30, 200)) + [-100000, 10000]
    6565        b = miditofreq(a)
    6666        #print zip(a, b)
     
    7070
    7171    def test_miditobin(self):
    72         a = range(-30, 200) + [-100000, 10000]
     72        a = list(range(-30, 200)) + [-100000, 10000]
    7373        b = [ bintomidi(x, 44100, 512) for x in a ]
    7474        #print zip(a, b)
     
    7878
    7979    def test_bintomidi(self):
    80         a = range(-100, 512)
     80        a = list(range(-100, 512))
    8181        b = [ bintomidi(x, 44100, 512) for x in a ]
    8282        #print zip(a, b)
     
    8686
    8787    def test_freqtobin(self):
    88         a = range(-20, 50000, 100) + [ -1e32, 1e32 ]
     88        a = list(range(-20, 50000, 100)) + [ -1e32, 1e32 ]
    8989        b = [ freqtobin(x, 44100, 512) for x in a ]
    9090        #print zip(a, b)
     
    9494
    9595    def test_bintofreq(self):
    96         a = range(-20, 148)
     96        a = list(range(-20, 148))
    9797        b = [ bintofreq(x, 44100, 512) for x in a ]
    9898        #print zip(a, b)
  • python/tests/test_musicutils.py

    r1c6fe64 r689106e  
    1818        try:
    1919            window(10, 1024)
    20         except ValueError, e:
     20        except ValueError as e:
    2121            pass
    2222        else:
     
    2626        try:
    2727            window("default", "default")
    28         except ValueError, e:
     28        except ValueError as e:
    2929            pass
    3030        else:
     
    4444        try:
    4545            level_lin("default")
    46         except ValueError, e:
     46        except ValueError as e:
    4747            pass
    4848        else:
     
    6363        try:
    6464            db_spl("default")
    65         except ValueError, e:
     65        except ValueError as e:
    6666            pass
    6767        else:
     
    8383        try:
    8484            silence_detection("default", -70)
    85         except ValueError, e:
     85        except ValueError as e:
    8686            pass
    8787        else:
     
    103103        try:
    104104            level_detection("default", -70)
    105         except ValueError, e:
     105        except ValueError as e:
    106106            pass
    107107        else:
  • python/tests/test_phasevoc.py

    r1c6fe64 r689106e  
    6464        zeros = fvec(hop_s)
    6565        f = pvoc(buf_s, hop_s)
    66         for i in xrange(hop_s):
     66        for i in range(hop_s):
    6767            sigin[i] = random() * 2. - 1.
    6868        t2 = f.rdo( f(sigin) )
  • python/tests/test_pitch.py

    r1c6fe64 r689106e  
    2525        p = pitch('default', 2048, 512, 32000)
    2626        f = fvec (512)
    27         for i in xrange(10): assert_equal (p(f), 0.)
     27        for i in range(10): assert_equal (p(f), 0.)
    2828
    2929    def test_run_on_ones(self):
     
    3232        f = fvec (512)
    3333        f[:] = 1
    34         for i in xrange(10): assert_equal (p(f), 0.)
     34        for i in range(10): assert_equal (p(f), 0.)
    3535
    3636class aubio_pitch_Sinusoid(TestCase):
  • python/tests/test_sink.py

    r1c6fe64 r689106e  
    4545                    vec = fvec(write)
    4646                    g(vec, write)
    47         except StandardError:
     47        except Exception:
    4848            pass
    4949        else:
     
    7171                    if read < f.hop_size: break
    7272                if 0:
    73                     print "read", "%.2fs" % (total_frames / float(f.samplerate) ),
    74                     print "(", total_frames, "frames", "in",
    75                     print total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")",
    76                     print "from", f.uri,
    77                     print "to", g.uri
     73                    print ("read", "%.2fs" % (total_frames / float(f.samplerate) ) ),
     74                    print ("(", total_frames, "frames", "in" ),
     75                    print (total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")" ),
     76                    print ("from", f.uri ),
     77                    print ("to", g.uri)
    7878                del_tmp_sink_path(sink_path)
    7979
     
    9696                    if read < f.hop_size: break
    9797                if 0:
    98                     print "read", "%.2fs" % (total_frames / float(f.samplerate) ),
    99                     print "(", total_frames, "frames", "in",
    100                     print f.channels, "channels", "in",
    101                     print total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")",
    102                     print "from", f.uri,
    103                     print "to", g.uri,
    104                     print "in", g.channels, "channels"
     98                    print ("read", "%.2fs" % (total_frames / float(f.samplerate) ) ),
     99                    print ("(", total_frames, "frames", "in" ),
     100                    print (f.channels, "channels", "in" ),
     101                    print (total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")" ),
     102                    print ("from", f.uri ),
     103                    print ("to", g.uri ),
     104                    print ("in", g.channels, "channels")
    105105                del_tmp_sink_path(sink_path)
    106106
  • python/tests/test_source.py

    r1c6fe64 r689106e  
    3939            total_frames += read
    4040            if read < f.hop_size: break
    41         print "read", "%.2fs" % (total_frames / float(f.samplerate) ),
    42         print "(", total_frames, "frames", "in",
    43         print total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")",
    44         print "from", f.uri
     41        print ("read", "%.2fs" % (total_frames / float(f.samplerate) ) ),
     42        print ("(", total_frames, "frames", "in" ),
     43        print (total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")" ),
     44        print ("from", f.uri)
    4545        return total_frames
    4646
     
    6868            try:
    6969                f = source(p, -1)
    70             except ValueError, e:
     70            except ValueError as e:
    7171                pass
    7272            else:
     
    7777            try:
    7878                f = source(p, 0, -1)
    79             except ValueError, e:
     79            except ValueError as e:
    8080                pass
    8181            else:
     
    109109            total_frames += read
    110110            if read < f.hop_size: break
    111         print "read", "%.2fs" % (total_frames / float(f.samplerate) ),
    112         print "(", total_frames, "frames", "in",
    113         print f.channels, "channels and",
    114         print total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")",
    115         print "from", f.uri
     111        print ("read", "%.2fs" % (total_frames / float(f.samplerate) ) ),
     112        print ("(", total_frames, "frames", "in" ),
     113        print (f.channels, "channels and" ),
     114        print (total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")" ),
     115        print ("from", f.uri)
    116116        return total_frames
    117117
Note: See TracChangeset for help on using the changeset viewer.