Skip to content

Commit

Permalink
Add test for FeatureSet with ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
CJStadler committed Jul 17, 2019
1 parent ffd07f0 commit 00b02fb
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions featuretools/tests/computational_backend/test_feature_set.py
@@ -1,6 +1,8 @@
import featuretools as ft
from featuretools.computational_backends.feature_set import FeatureSet
from featuretools.entityset.relationship import RelationshipPath
from featuretools.tests.testing_utils import backward_path
from featuretools.utils import Trie


def test_feature_trie_without_needs_full_entity(diamond_es):
Expand Down Expand Up @@ -104,3 +106,28 @@ def test_feature_trie_with_needs_full_entity_direct(es):

assert child_through_parent_node.get_node(agg.relationship_path).value == \
(True, {value.unique_name()}, set())


def test_feature_trie_with_ignored_features(es):
value = ft.IdentityFeature(es['log']['value'],)
agg = ft.AggregationFeature(value, es['sessions'],
primitive=ft.primitives.Mean)
agg_of_agg = ft.AggregationFeature(agg, es['customers'],
primitive=ft.primitives.Sum)
direct = ft.DirectFeature(agg_of_agg, es['sessions'])
features = [direct, agg]

ignored_features = Trie(default=list, path_constructor=RelationshipPath)
ignored_features.get_node(direct.relationship_path).value = [agg_of_agg]
feature_set = FeatureSet(features, ignored_feature_trie=ignored_features)
trie = feature_set.feature_trie

# Since agg_of_agg is ignored it and its dependencies should not be in the
# trie.
sub_trie = trie.get_node(direct.relationship_path)
for _path, (_, _, features) in sub_trie:
assert not features

assert trie.value == (False, set(), {direct.unique_name(), agg.unique_name()})
assert trie.get_node(agg.relationship_path).value == \
(False, set(), {value.unique_name()})

0 comments on commit 00b02fb

Please sign in to comment.