def test_sequence_generator_invalid_noise_type(): with pytest.raises(AssertionError): timesequence_generator( t_min=0, t_max=50, n_max=200, noise_type='badstring')
def test_sequence_generator1(t_min, t_max, n_max, n_timestamps): with pytest.raises(ValueError): timesequence_generator( t_min=t_min, t_max=t_max, n_max=n_max, n_timestamps=n_timestamps)
def test_sequence_generator2(n_min, n_max): with pytest.raises(AssertionError): timesequence_generator( t_min=0, t_max=50, n_max=n_max, n_min=n_min)
def test_sequence_generator_pareto(pareto_shape): with pytest.raises(AssertionError): timesequence_generator( t_min=0, t_max=50, n_max=200, noise_type='pareto', pareto_shape=pareto_shape)
def test_sequence_generator_jitter(delta): with pytest.raises(AssertionError): timesequence_generator( t_min=0, t_max=50, n_max=200, noise_type='jitter', delta=delta)
def test_wave_with_no_noise(): sequence_generator = timesequence_generator(t_min=0.0, t_max=50.0, n_max=201) ts = sequence_generator() params = { 'amplitude': { 'mean': 1 }, 'frequency': { 'mean': 1 }, } wave = Wave(**params) wave.generate(ts) assert wave.noise == 0
def test_wave_with_delayed_size(): sequence_generator = timesequence_generator(t_min=0.0, t_max=50.0, n_max=201) ts = sequence_generator() params = { 'amplitude': { 'mean': 2 }, 'frequency': { 'mean': 2 }, } wave = Wave(**params) wave.generate(ts) assert len(wave.sample) == len(ts)
def test_wave_with_3_features(): n_timestamps = 201 features = ('d0xdt0', 'd3xdt3', 'd2xdt2') sequence_generator = timesequence_generator(t_min=0.0, t_max=2.0, n_max=n_timestamps) ts = sequence_generator() params = { 'amplitude': { 'mean': 1 }, 'frequency': { 'mean': 1 }, } wave = Wave(*features, **params) wave.generate(ts) assert wave.inputs.shape == (n_timestamps, len(features))
def test_wave_raises_invalid_feature(): n_timestamps = 201 features = ('dydz2', ) sequence_generator = timesequence_generator(t_min=0.0, t_max=2.0, n_max=n_timestamps) ts = sequence_generator() params = { 'amplitude': { 'mean': 1 }, 'frequency': { 'mean': 1 }, } with pytest.raises(ValueError): wave = Wave(*features, **params) wave.generate(ts) _ = wave.inputs
def test_wave_with_timestamp_noise(n_min, n_max, noise_type, delta, pareto_shape): sequence_generator = timesequence_generator(t_min=0.0, t_max=50.0, n_max=n_max, n_min=n_min, noise_type=noise_type, delta=delta, pareto_shape=pareto_shape) ts = sequence_generator() params = { 'amplitude': { 'mean': 1 }, 'frequency': { 'mean': 1 }, } wave = Wave(**params) wave.generate(ts) assert len(wave.sample) == len(ts)
def test_wave_with_normal_noise(): sequence_generator = timesequence_generator(t_min=0.0, t_max=50.0, n_max=201) ts = sequence_generator() params = { 'amplitude': { 'mean': 1 }, 'frequency': { 'mean': 1 }, 'noise': { 'normal': { 'mu': 0.0, 'sigma': 0.5 } }, } wave = Wave(**params) wave.generate(ts) assert len(wave.noise) == len(ts)
def test_wave_mean(): sequence_generator = timesequence_generator(t_min=0.0, t_max=50.0, n_max=201) ts = sequence_generator() params = { 'amplitude': { 'mean': 1, 'delta': 0 }, 'frequency': { 'mean': 5, 'delta': 0 }, 'offset': { 'mean': -3, 'delta': 0 }, 'phase': { 'mean': 2, 'delta': 0 }, 'name': 'A', 'color': '#ff0000' } wave = Wave(**params) assert wave.amplitude == 1 assert wave.frequency == 5 assert wave.offset == -3 assert wave.phase == 2 assert wave.name == 'A' assert wave.color == '#ff0000' wave.generate(ts, amplitude=1, frequency=1, offset=1, phase=1) assert wave.amplitude == 1 assert wave.frequency == 5 assert wave.offset == -3 assert wave.phase == 2 assert wave.noise == 0