예제 #1
0
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')
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
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
예제 #7
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)
예제 #8
0
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))
예제 #9
0
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
예제 #10
0
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)
예제 #11
0
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)
예제 #12
0
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