Passing strings to variable_types - #988
Conversation
…y_from_dataframe function
Codecov Report
@@ Coverage Diff @@
## master #988 +/- ##
==========================================
+ Coverage 98.25% 98.27% +0.01%
==========================================
Files 119 119
Lines 11030 11076 +46
==========================================
+ Hits 10838 10885 +47
+ Misses 192 191 -1
Continue to review full report at Codecov.
|
…es.entity_from_dataframe function
|
|
||
| entity = es["reversed_variable_types"] | ||
| for variable in entity.variables: | ||
| description = variable.to_data_description() |
There was a problem hiding this comment.
I think we can test the variable types were set correctly more directly by checking the class of each variable in the entity without serializing the variables
… the variable types directly. Added a testing for passing strings as variable types within the dfs function
| variable_types[vid] = string_to_class_map[vtype] | ||
| else: | ||
| variable_types[vid] = string_to_class_map['unknown'] | ||
| warnings.warn("Variable type {} was unrecognized, Unknown Class was used instead".format(vtype)) |
There was a problem hiding this comment.
instead of "Unknown Class" let's say "Unknown variable type"
| entity = es["reversed_variable_types"] | ||
| for variable in entity.variables: | ||
| variable_class = variable.__class__ | ||
| assert variable_class == variable_types[variable_class.type_string] |
There was a problem hiding this comment.
I think we should compare the variable_class to the matching variable in the reversed_variable_types dictionary since that was the dictionary used for variable_types
| for variable in entity.variables: | ||
| description = variable.to_data_description() | ||
| _variable = deserialize.description_to_variable(description, entity=entity) | ||
| assert variable.__eq__(_variable) |
There was a problem hiding this comment.
this test should use the same approach as test_passing_strings_to_variable_types_from_dataframe
| entities = {'teams': (teams, 'id', None, {'name': 'text'}), 'games': (games, 'id')} | ||
| relationships = [('teams', 'id', 'games', 'home_team_id')] | ||
|
|
||
| _, features = ft.dfs(entities, relationships, target_entity="teams") |
There was a problem hiding this comment.
adding the optional parameter features_only=True will make dfs only return the features list
| relationships = [('teams', 'id', 'games', 'home_team_id')] | ||
|
|
||
| _, features = ft.dfs(entities, relationships, target_entity="teams") | ||
| name_class = features[0].entity.variables[1].__class__ |
There was a problem hiding this comment.
An entity's variables can be looked up by name directly from the entity object
features[0].entity['name'].__class__
Small change but I think it makes the test a little easier to follow
…into iss946 adding cleaning up description_to_entity by using type_strings
Pull Request Description
Allows the passing of strings into the variable types dict.
After creating the pull request: in order to pass the changelog_updated check you will need to update the "Future Release" section of
docs/source/changelog.rstto include this pull request.