Skip to content

Conversation

@christopherbunn
Copy link
Contributor

@christopherbunn christopherbunn 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
Copy link

CLAassistant commented Sep 3, 2019

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot 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.

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Contributor

@rwedge rwedge Sep 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

@rwedge rwedge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@christopherbunn christopherbunn merged commit de04288 into master Sep 4, 2019
@christopherbunn christopherbunn deleted the raise-time-index branch September 4, 2019 13:42
@rwedge rwedge mentioned this pull request Sep 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle case where DatetimeTimeIndex is set as variable type, but not specified as time index

4 participants