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

Fix variable types modify in Entity init #675

Merged
merged 5 commits into from Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -8,6 +8,7 @@ Changelog
* Fixes
* Fix performance regression in DFS (:pr:`637`)
* Fix deserialization of feature relationship path (:pr:`665`)
* Fix user-supplied variable_types modification in Entity init (:pr:`675`)
* Changes
* Moved dask, distributed imports (:pr:`634`)
* Documentation Changes
Expand Down
2 changes: 1 addition & 1 deletion featuretools/entityset/entity.py
Expand Up @@ -285,7 +285,7 @@ def _create_variables(self, variable_types, index, time_index, secondary_time_in
that each map to a list of columns that depend on that secondary time
"""
variables = []
variable_types = variable_types or {}
variable_types = variable_types.copy() or {}
if index not in variable_types:
variable_types[index] = vtypes.Index

Expand Down
16 changes: 16 additions & 0 deletions featuretools/tests/entityset_tests/test_entity.py
Expand Up @@ -127,3 +127,19 @@ def test_delete_variables(es):
for var in to_delete:
assert var not in variable_names
assert var not in entity.df


def test_variable_types_unmodified():
df = pd.DataFrame({"id": [1, 2, 3, 4, 5, 6],
"transaction_time": [10, 12, 13, 20, 21, 20],
"fraud": [True, False, False, False, True, True]})

es = ft.EntitySet()
variable_types = {'fraud': ft.variable_types.Boolean}
old_variable_types = variable_types.copy()
es.entity_from_dataframe(entity_id="transactions",
dataframe=df,
index='id',
time_index='transaction_time',
variable_types=variable_types)
assert old_variable_types == variable_types