def test_linear_space(self): for _ in range(0, self.__number_inputs): size = randint(-self.__minimum_size, self.__maximum_size) minimum = randint(self.__minimum_size, self.__maximum_size / 1000) maximum = randint(minimum, self.__maximum_size) generated = algorithm.linspace(minimum, maximum, size) reference = np.linspace(minimum, maximum, size) np.testing.assert_array_almost_equal(generated, reference)
def test_centspace(self): for _ in range(100): min_f = random.uniform(self.__minimum_frequency, self.__maximum_frequency) max_f = random.uniform(min_f, self.__maximum_frequency) n = random.randint(0, self.__maximum_size) frequencies = algorithm.linspace(min_f, max_f, n) generated = auditory.centspace(min_f, max_f, n) for f, bark in zip(frequencies, generated): self.assertAlmostEqual(auditory.hertz2cent(f), bark)