def test_add_frequency_data_and_number(): # generate and add signals x = FrequencyData([1, 0, 0], [0, .1, .5]) y = signal.add((x, 1), 'freq') with raises(ValueError): signal.add((x, 1), 'time') # check if old signal did not change npt.assert_allclose(x.freq, np.atleast_2d([1, 0, 0]), atol=1e-15) npt.assert_allclose(x.frequencies, np.atleast_1d([0, .1, .5]), atol=1e-15) # check result assert isinstance(y, FrequencyData) npt.assert_allclose(y.freq, np.atleast_2d([2, 1, 1]), atol=1e-15) npt.assert_allclose(y.frequencies, np.atleast_1d([0, .1, .5]), atol=1e-15)
def test_add_two_signals_time(): # generate test signal x = Signal([1, 0, 0], 44100) # time domain y = signal.add((x, x), 'time') # check if old signal did not change npt.assert_allclose(x.time, np.atleast_2d([1, 0, 0]), atol=1e-15) # check result assert isinstance(y, Signal) assert y.domain == 'time' npt.assert_allclose(y.time, np.atleast_2d([2, 0, 0]), atol=1e-15)
def test_add_number_and_signal(): # generate and add signals x = Signal([1, 0, 0], 44100) y = signal.add((1, x), 'time') # check if old signal did not change npt.assert_allclose(x.time, np.atleast_2d([1, 0, 0]), atol=1e-15) # check result assert isinstance(y, Signal) assert y.domain == 'time' npt.assert_allclose(y.time, np.atleast_2d([2, 1, 1]), atol=1e-15)
def test_add_time_data_and_time_data(): # generate and add signals x = TimeData([1, 0, 0], [0, .1, .5]) y = signal.add((x, x), 'time') # check if old signal did not change npt.assert_allclose(x.time, np.atleast_2d([1, 0, 0]), atol=1e-15) npt.assert_allclose(x.times, np.atleast_1d([0, .1, .5]), atol=1e-15) # check result assert isinstance(y, TimeData) npt.assert_allclose(y.time, np.atleast_2d([2, 0, 0]), atol=1e-15) npt.assert_allclose(y.times, np.atleast_1d([0, .1, .5]), atol=1e-15)
def test_add_frequency_data_and_number_wrong_fft_norm(): # generate and add signals x = FrequencyData([1, 0, 0], [0, .1, .5]) y = FrequencyData([1, 0, 0], [0, .1, .5], fft_norm='rms') with raises(ValueError): signal.add((x, y), 'freq')
def test_add_frequency_data_and_number_wrong_domain(): # generate and add signals x = FrequencyData([1, 0, 0], [0, .1, .5]) with raises(ValueError): signal.add((x, 1), 'time')
def test_add_time_data_and_number_wrong_times(): # generate and add signals x = TimeData([1, 0, 0], [0, .1, .5]) y = TimeData([1, 0, 0], [0, .1, .4]) with raises(ValueError): signal.add((x, y), 'time')
def test_add_time_data_and_number_wrong_domain(): # generate and add signals x = TimeData([1, 0, 0], [0, .1, .5]) with raises(ValueError): signal.add((x, 1), 'freq')