def test_invalid_filepath(self): with self.assertRaises(IOError): core.Contours(self.index, self.times, self.freqs, self.salience, self.sample_rate, audio_filepath='not/a/file.wav')
def test_invalid_contours(self): with self.assertRaises(ValueError): core.Contours(self.index, self.times, self.freqs[:-1], self.salience, self.sample_rate, audio_filepath=self.audio_filepath)
def test_invalid_audio(self): with self.assertRaises(ValueError): core.Contours(self.index, self.times, self.freqs, self.salience, self.sample_rate, audio_filepath=None, audio_duration=None)
def setUp(self): self.index = np.array([0, 0, 1, 1, 1, 2]) self.times = np.array([0.0, 0.1, 0.0, 0.1, 0.2, 0.5]) self.freqs = np.array([440.0, 441.0, 50.0, 52.0, 55.0, 325.2]) self.salience = np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) self.sample_rate = 10.0 self.audio_filepath = AUDIO_FILE self.ctr = core.Contours(self.index, self.times, self.freqs, self.salience, self.sample_rate, self.audio_filepath)
def setUp(self): self.dcd = maximum.MaxDecoder() self.index = np.array([0, 0, 1, 1, 1, 2]) self.times = np.array([0.0, 0.1, 0.0, 0.1, 0.2, 0.5]) self.freqs = np.array([440.0, 441.0, 50.0, 52.0, 55.0, 325.2]) self.salience = np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) self.sample_rate = 10.0 self.ctr = core.Contours(self.index, self.times, self.freqs, self.salience, self.sample_rate, audio_duration=0.5) self.Y1 = np.array([0.9, 0.7, 0.1]) self.Y2 = np.array([0.9, 0.1, 0.8])
def test_compute_all(self): index = np.array([0, 0, 1, 1, 1, 2]) times = np.array([0.0, 0.1, 0.0, 0.1, 0.2, 0.5]) freqs = np.array([440.0, 441.0, 50.0, 52.0, 55.0, 325.2]) salience = np.array([0.2, 0.4, 0.5, 0.2, 0.4, 0.0]) sample_rate = 10.0 ctr = core.Contours(index, times, freqs, salience, sample_rate, AUDIO_FILE) expected = np.array([[ 0.0, 0.1, 0.1, 3601.96508, 1.96507922, 0.6, 0.2, 1.2, 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.2, 0.2, -87.3694077, 67.7134674, 0.733333333, .249443826, 2.20000000, 0.0, 0.0, 0.0, 0.0 ], [ 0.5, 0.5, 0.0, 3076.58848, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]]) actual = self.ftr.compute_all(ctr) self.assertTrue(array_equal(expected, actual))