Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use mock_customer fixture #1036

Merged
merged 22 commits into from Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/changelog.rst
Expand Up @@ -18,6 +18,7 @@ Changelog
* Add development install instructions to contributing.md (:pr:`1030`)
* Testing Changes
* Add ``required`` flag to CircleCI codecov upload command (:pr:`1035`)
* Add fixture for ``ft.demo.load_mock_customer`` (:pr:`1036`)
systemshift marked this conversation as resolved.
Show resolved Hide resolved

Thanks to the following people for contributing to this release:
:user:`tuethan1999`, :user:`kmax12`, :user:`thehomebrewnerd`, :user:`gsheni`, :user:`frances-h`
systemshift marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Expand Up @@ -1455,11 +1455,6 @@ def test_string_time_values_in_cutoff_time(es):
calculate_feature_matrix([agg_feature], es, cutoff_time=cutoff_time)


@pytest.fixture
def pd_mock_customer():
return ft.demo.load_mock_customer(return_entityset=True, random_seed=0)


@pytest.fixture
def dd_mock_customer(pd_mock_customer):
dd_mock_customer = copy.deepcopy(pd_mock_customer)
systemshift marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
5 changes: 5 additions & 0 deletions featuretools/tests/conftest.py
Expand Up @@ -150,3 +150,8 @@ def games_es(home_games_es):
away_team = ft.Relationship(home_games_es['teams']['id'],
home_games_es['games']['away_team_id'])
return home_games_es.add_relationship(away_team)


@pytest.fixture
def pd_mock_customer():
return ft.demo.load_mock_customer(return_entityset=True, random_seed=0)
6 changes: 3 additions & 3 deletions featuretools/tests/demo_tests/test_demo_data.py
Expand Up @@ -2,7 +2,7 @@

import pytest

from featuretools.demo import load_flight, load_mock_customer, load_retail
from featuretools.demo import load_flight, load_retail
from featuretools.synthesis import dfs


Expand All @@ -22,8 +22,8 @@ def test_load_retail_diff():
assert es_second['order_products'].df.shape[0] == nrows_second


def test_mock_customer():
es = load_mock_customer(return_entityset=True)
def test_mock_customer(pd_mock_customer):
es = pd_mock_customer
systemshift marked this conversation as resolved.
Show resolved Hide resolved
fm, fl = dfs(entityset=es, target_entity="customers", max_depth=3)
for feature in fl:
assert feature.get_name() in fm.columns
Expand Down
5 changes: 2 additions & 3 deletions featuretools/tests/entityset_tests/test_serialization.py
Expand Up @@ -6,7 +6,6 @@
import pytest
from dask import dataframe as dd

from featuretools.demo import load_mock_customer
from featuretools.entityset import EntitySet, deserialize, serialize
from featuretools.variable_types import (
Categorical,
Expand Down Expand Up @@ -214,8 +213,8 @@ def test_to_parquet_interesting_values(pd_es, tmpdir):
assert pd_es.__eq__(new_es, deep=True)


def test_to_parquet_with_lti(tmpdir):
es = load_mock_customer(return_entityset=True, random_seed=0)
def test_to_parquet_with_lti(tmpdir, pd_mock_customer):
es = pd_mock_customer
es.to_parquet(str(tmpdir))
new_es = deserialize.read_entityset(str(tmpdir))
assert es.__eq__(new_es, deep=True)
Expand Down
Expand Up @@ -36,8 +36,9 @@ def maximum(column):


# Check the successful default value for custom aggregation primitives
def test_default_value_make_agg_primitive():
pd_es = ft.demo.load_mock_customer(return_entityset=True)


def test_default_value_make_agg_primitive(pd_mock_customer):

def mean_sunday(numeric, datetime):
'''
Expand All @@ -51,7 +52,7 @@ def mean_sunday(numeric, datetime):
input_types=[Numeric, Datetime],
return_type=Numeric)

feature_matrix, features = ft.dfs(entityset=pd_es,
feature_matrix, features = ft.dfs(entityset=pd_mock_customer,
target_entity="sessions",
agg_primitives=[MeanSunday],
trans_primitives=[],
Expand All @@ -62,7 +63,7 @@ def mean_sunday(numeric, datetime):
return_type=Numeric,
default_value=0)

feature_matrix2, features = ft.dfs(entityset=pd_es,
feature_matrix2, features = ft.dfs(entityset=pd_mock_customer,
target_entity="sessions",
agg_primitives=[MeanSundayDefault],
trans_primitives=[],
Expand Down
12 changes: 3 additions & 9 deletions featuretools/tests/utils_tests/test_entity_utils.py
Expand Up @@ -5,7 +5,6 @@
import pandas as pd
import pytest

import featuretools as ft
from featuretools import variable_types as vtypes
from featuretools.utils.entity_utils import (
convert_all_variable_data,
Expand All @@ -17,19 +16,14 @@


@pytest.fixture
def pd_mock_customer_es():
return ft.demo.load_mock_customer(return_entityset=True, random_seed=0)


@pytest.fixture
def dask_mock_customer_es(pd_mock_customer_es):
dask_es = copy.deepcopy(pd_mock_customer_es)
def dask_mock_customer_es(pd_mock_customer):
dask_es = copy.deepcopy(pd_mock_customer)
systemshift marked this conversation as resolved.
Show resolved Hide resolved
for entity in dask_es.entities:
entity.df = dd.from_pandas(entity.df.reset_index(drop=True), npartitions=2)
return dask_es


@pytest.fixture(params=['pd_mock_customer_es', 'dask_mock_customer_es'])
@pytest.fixture(params=['pd_mock_customer', 'dask_mock_customer_es'])
systemshift marked this conversation as resolved.
Show resolved Hide resolved
def mock_customer_es(request):
return request.getfixturevalue(request.param)

Expand Down