Beispiel #1
0
def test_as_dict(foo_extractor):
    rs = FeatureSet(
        features_names=["foo"],
        values={"foo": 1},
        timeserie=TIME_SERIE,
        extractors={"foo": foo_extractor},
    )
    assert rs.as_dict() == {"foo": 1}
Beispiel #2
0
def test_plot(foo_extractor):
    rs = FeatureSet(
        features_names=["foo"],
        values={"foo": 1},
        timeserie=TIME_SERIE,
        extractors={"foo": foo_extractor},
    )

    assert isinstance(rs.plot("foo"), axes.Axes)
Beispiel #3
0
def test_as_dataframe(foo_extractor):
    rs = FeatureSet(
        features_names=["foo"],
        values={"foo": 1},
        timeserie=TIME_SERIE,
        extractors={"foo": foo_extractor},
    )

    expected = pd.DataFrame([{"foo": 1.0}])
    assert rs.as_dataframe().equals(expected)
Beispiel #4
0
def test_as_array(foo_extractor):
    rs = FeatureSet(
        features_names=["foo"],
        values={"foo": 1},
        timeserie=TIME_SERIE,
        extractors={"foo": foo_extractor},
    )
    feats, values = rs.as_arrays()
    assert list(feats) == unordered(["foo"])
    assert list(values) == unordered([1])
Beispiel #5
0
def test_invalid_feature():
    with pytest.raises(FeatureNotFound):
        FeatureSet(
            features_names=["Fail"],
            values={"fail": 1},
            timeserie=TIME_SERIE,
            extractors={},
        )
Beispiel #6
0
def test_getitem(foo_extractor):
    rs = FeatureSet(
        features_names=["foo"],
        values={"foo": 1},
        timeserie=TIME_SERIE,
        extractors={"foo": foo_extractor},
    )

    assert rs["foo"] == 1
    with pytest.raises(KeyError):
        rs["faaa"]
Beispiel #7
0
def test_repr(foo_extractor):
    timeserie = TIME_SERIE.copy()
    timeserie.update(time=1, error=2)

    rs = FeatureSet(
        features_names=["foo"],
        values={"foo": 1},
        timeserie=timeserie,
        extractors={"foo": foo_extractor},
    )
    expected = "FeatureSet(features=<foo>, timeserie=<time, error>)"
    assert repr(rs) == str(rs) == expected