Changeset 376d5e9


Ignore:
Timestamp:
Apr 18, 2016, 11:46:18 PM (3 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
81ad577, e76842e
Parents:
6db7600
Message:

tests/: continue python3 preparation

Location:
python/tests
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_filterbank.py

    r6db7600 r376d5e9  
    1717  def test_set_coeffs(self):
    1818    f = filterbank(40, 512)
    19     r = random.random([40, 512 / 2 + 1]).astype('float32')
     19    r = random.random([40, int(512 / 2) + 1]).astype('float32')
    2020    f.set_coeffs(r)
    2121    assert_equal (r, f.get_coeffs())
     
    3636    f = filterbank(40, 512)
    3737    c = cvec(512)
    38     c.norm[:] = random.random((512 / 2 + 1,)).astype('float32')
     38    c.norm[:] = random.random((int(512 / 2) + 1,)).astype('float32')
    3939    assert_equal( f(c), 0)
    4040
     
    4242    f = filterbank(40, 512)
    4343    c = cvec(512)
    44     r = random.random([40, 512 / 2 + 1]).astype('float32')
     44    r = random.random([40, int(512 / 2) + 1]).astype('float32')
    4545    r /= r.sum()
    4646    f.set_coeffs(r)
    47     c.norm[:] = random.random((512 / 2 + 1,)).astype('float32')
     47    c.norm[:] = random.random((int(512 / 2) + 1,)).astype('float32')
    4848    assert_equal ( f(c) < 1., True )
    4949    assert_equal ( f(c) > 0., True )
     
    5353    c = cvec(512)
    5454    f.set_mel_coeffs_slaney(44100)
    55     c.norm[:] = random.random((512 / 2 + 1,)).astype('float32')
     55    c.norm[:] = random.random((int(512 / 2) + 1,)).astype('float32')
    5656    assert_equal ( f(c) < 1., True )
    5757    assert_equal ( f(c) > 0., True )
  • python/tests/test_note2midi.py

    r6db7600 r376d5e9  
    7070    def test_freq2note(self):
    7171        " make sure freq2note(441) == A4 "
    72         self.assertEquals("A4", freq2note(441))
     72        self.assertEqual("A4", freq2note(441))
    7373
    7474if __name__ == '__main__':
  • python/tests/test_phasevoc.py

    r6db7600 r376d5e9  
    3131        f = pvoc (win_s, hop_s)
    3232        t = fvec (hop_s)
    33         for time in range( 4 * win_s / hop_s ):
     33        for time in range( int ( 4 * win_s / hop_s ) ):
    3434            s = f(t)
    3535            r = f.rdo(s)
  • python/tests/test_zero_crossing_rate.py

    r6db7600 r376d5e9  
    2323    def test_impulse(self):
    2424        """ check zero crossing rate on a buffer with an impulse """
    25         self.vector[buf_size / 2] = 1.
     25        self.vector[int(buf_size / 2)] = 1.
    2626        self.assertEqual(0., zero_crossing_rate(self.vector))
    2727
    2828    def test_negative_impulse(self):
    2929        """ check zero crossing rate on a buffer with a negative impulse """
    30         self.vector[buf_size / 2] = -1.
     30        self.vector[int(buf_size / 2)] = -1.
    3131        self.assertEqual(2./buf_size, zero_crossing_rate(self.vector))
    3232
    3333    def test_single(self):
    3434        """ check zero crossing rate on single crossing """
    35         self.vector[buf_size / 2 - 1] = 1.
    36         self.vector[buf_size / 2] = -1.
     35        self.vector[int(buf_size / 2) - 1] = 1.
     36        self.vector[int(buf_size / 2)] = -1.
    3737        self.assertEqual(2./buf_size, zero_crossing_rate(self.vector))
    3838
    3939    def test_single_with_gap(self):
    4040        """ check zero crossing rate on single crossing with a gap"""
    41         self.vector[buf_size / 2 - 2] = 1.
    42         self.vector[buf_size / 2] = -1.
     41        self.vector[int(buf_size / 2) - 2] = 1.
     42        self.vector[int(buf_size / 2)] = -1.
    4343        self.assertEqual(2./buf_size, zero_crossing_rate(self.vector))
    4444
  • python/tests/utils.py

    r6db7600 r376d5e9  
    55    from numpy import array
    66    filename = os.path.join(os.path.dirname(__file__), filename)
    7     return array([line.split() for line in open(filename).readlines()],
    8         dtype = dtype)
     7    with open(filename) as f:
     8        lines = f.readlines()
     9    return array([line.split() for line in lines],
     10            dtype = dtype)
    911
    1012def list_all_sounds(rel_dir):
Note: See TracChangeset for help on using the changeset viewer.