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
Refactor EntitySet.find_path(...) #295
Conversation
Codecov Report
@@ Coverage Diff @@
## master #295 +/- ##
==========================================
+ Coverage 95.01% 95.04% +0.02%
==========================================
Files 71 71
Lines 7627 7621 -6
==========================================
- Hits 7247 7243 -4
+ Misses 380 378 -2
Continue to review full report at Codecov.
|
# Conflicts: # .circleci/config.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring for this method still references BaseEntitySet
, which should probably be changed. The description of the return values also refers to include_num_forward
as include_forward_distance
.
featuretools/entityset/entityset.py
Outdated
start_node = BFSNode(start_entity_id, None, None) | ||
queue = [start_node] | ||
nodes = {} | ||
# Search for bath using BFS to get the shortest path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Search for path
featuretools/entityset/entityset.py
Outdated
for r in next_relationships: | ||
queue.append(current_path + [r]) | ||
|
||
visited.add(next_entity_id) | ||
|
||
raise ValueError(("No path from {} to {}! Check that all entities " | ||
.format(start_entity_id, goal_entity_id)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not tested according to codecov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
:func:`BaseEntitySet.find_forward_path` | ||
:func:`BaseEntitySet.find_backward_path` | ||
:func:`EntitySet.find_forward_path` | ||
:func:`EntitySet.find_backward_path` | ||
""" | ||
if start_entity_id == goal_entity_id: | ||
if include_num_forward: | ||
return [], 0 | ||
else: | ||
return [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This else case not tested according to codecov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
Looks good |
This PR simply rewrites the bread first search algorithm we use to find a path between two nodes.
Our existing approach defined an new class to do it, which resulted in bloated code.
The changes here remove that extra class and adds comments to create cleaner and more understandable code.