예제 #1
0
def test_trigger_tags(mock_tag_normalizer):
    data_provider = MockDataProvider()
    dataset = TimeSeriesDataset(
        data_provider=data_provider,
        tag_list=[
            SensorTag("Tag 1", None),
            SensorTag("Tag 2", None),
        ],
        target_tag_list=[
            SensorTag("Tag 5", None),
        ],
        train_start_date=dateutil.parser.isoparse("2017-12-25 06:00:00Z"),
        train_end_date=dateutil.parser.isoparse("2017-12-29 06:00:00Z"),
        row_filter="`Tag 3` > 0 & `Tag 4` > 1",
        tag_normalizer=mock_tag_normalizer,
    )
    X, y = dataset.get_data()
    assert X is not None
    assert y is not None
    assert set(data_provider.last_tag_list) == {
        SensorTag("Tag 1", None),
        SensorTag("Tag 2", None),
        SensorTag("Tag 3", None),
        SensorTag("Tag 4", None),
        SensorTag("Tag 5", None),
    }
    assert set(X.columns.values) == {"Tag 1", "Tag 2"}
    assert set(y.columns.values) == {"Tag 5"}
예제 #2
0
def test_insufficient_data_after_automatic_filtering():
    """
    Test that dataframe after row_filter scenarios raise appropriate
    InsufficientDataError
    """

    kwargs = dict(
        data_provider=MockDataProvider(),
        tag_list=[
            SensorTag("Tag 1", None),
            SensorTag("Tag 2", None),
            SensorTag("Tag 3", None),
        ],
        train_start_date=dateutil.parser.isoparse("2017-12-25 06:00:00Z"),
        train_end_date=dateutil.parser.isoparse("2017-12-29 06:00:00Z"),
        n_samples_threshold=84,
        filter_periods={"filter_method": "median"},
    )

    with pytest.raises(InsufficientDataError):
        TimeSeriesDataset(**kwargs).get_data()
예제 #3
0
def test_insufficient_data_after_known_filter_periods_filtering():
    """
    Test that dataframe after row_filter scenarios raise appropriate
    InsufficientDataError
    """

    kwargs = dict(
        data_provider=MockDataProvider(),
        tag_list=[
            SensorTag("Tag 1", None),
            SensorTag("Tag 2", None),
            SensorTag("Tag 3", None),
        ],
        train_start_date=dateutil.parser.isoparse("2017-12-25 06:00:00Z"),
        train_end_date=dateutil.parser.isoparse("2017-12-29 06:00:00Z"),
        n_samples_threshold=10,
        known_filter_periods=[
            "~('2017-12-25 07:00:00+00:00' <= index <= '2017-12-29 06:00:00+00:00')"
        ],
    )

    with pytest.raises(InsufficientDataError):
        TimeSeriesDataset(**kwargs).get_data()