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

Raise an error when DatetimeTimeIndex is a variable but time_index is empty #723

Merged
merged 9 commits into from Sep 4, 2019

Conversation

@christopherbunn
Copy link
Contributor

commented Sep 3, 2019

Added a ValueError message when a DatetimeTimeIndex is set as a variable but is not specified as a time_index

fixes #497

@CLAassistant

This comment has been minimized.

Copy link

commented Sep 3, 2019

CLA assistant check
All committers have signed the CLA.

@codecov

This comment has been minimized.

Copy link

commented Sep 3, 2019

Codecov Report

Merging #723 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #723      +/-   ##
==========================================
+ Coverage   97.63%   97.63%   +<.01%     
==========================================
  Files         118      118              
  Lines       10194    10205      +11     
==========================================
+ Hits         9953     9964      +11     
  Misses        241      241
Impacted Files Coverage Δ
featuretools/entityset/entityset.py 95.58% <100%> (+0.04%) ⬆️
featuretools/tests/entityset_tests/test_es.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7d9da15...8191531. Read the comment docs.

@christopherbunn christopherbunn requested a review from rwedge Sep 3, 2019
@@ -485,6 +485,9 @@ def entity_from_dataframe(self,
if time_index is not None and time_index == index:
raise ValueError("time_index and index cannot be the same value, %s" % (time_index))

if vtypes.DatetimeTimeIndex in variable_types.values() and time_index is None:
raise ValueError("'DatetimeTimeIndex' must be set using time_index parameter")

This comment has been minimized.

Copy link
@rwedge

rwedge Sep 3, 2019

Collaborator

We should include the variable name in the error message to help the user track down the source of the problem

@@ -485,6 +485,10 @@ def entity_from_dataframe(self,
if time_index is not None and time_index == index:
raise ValueError("time_index and index cannot be the same value, %s" % (time_index))

if vtypes.DatetimeTimeIndex in variable_types.values() and time_index is None:
var_name = variable_types.keys()[variable_types.values().index(vtypes.DatetimeTimeIndex)]

This comment has been minimized.

Copy link
@rwedge

rwedge Sep 3, 2019

Collaborator

This works but I think we can clean it up a bit

We can loop through variable_types.items() once and raise an error the first time we encounter the problem.

if time_index is None:
for variable, variable_type in variable_types.items():
if variable_type == vtypes.DatetimeTimeIndex:
raise ValueError("Variable %s must be set using time_index parameter" % (variable))

This comment has been minimized.

Copy link
@rwedge

rwedge Sep 3, 2019

Collaborator

Can you also include that the variable is DatetimeTimeIdex type, e.g. "DatetimeTimeIndex variable %s . . ."

@rwedge
rwedge approved these changes Sep 4, 2019
Copy link
Collaborator

left a comment

Looks good

@christopherbunn christopherbunn merged commit de04288 into master Sep 4, 2019
4 checks passed
4 checks passed
codecov/patch 100% of diff hit (target 97.63%)
Details
codecov/project 97.63% (+<.01%) compared to 7d9da15
Details
license/cla Contributor License Agreement is signed.
Details
test_all_python_versions Workflow: test_all_python_versions
Details
@christopherbunn christopherbunn deleted the raise-time-index branch Sep 4, 2019
@rwedge rwedge referenced this pull request Sep 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.