Skip to content

Commit

Permalink
Refine variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpai committed Jun 27, 2023
1 parent e6b53f6 commit c53e623
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions mars/optimization/logical/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _replace_node(self, original_node: EntityType, new_node: EntityType):
def _replace_subgraph(
self,
graph: Optional[EntityGraph],
removed_nodes: Optional[Set[EntityType]],
nodes_to_remove: Optional[Set[EntityType]],
new_results: Optional[List[Entity]] = None,
):
"""
Expand All @@ -146,7 +146,7 @@ def _replace_subgraph(
----------
graph : EntityGraph, optional
The input graph. If it's none, no new node and edge will be added.
removed_nodes : Set[EntityType], optional
nodes_to_remove : Set[EntityType], optional
The nodes to be removed. All the edges connected with them are removed as well.
new_results : List[EntityType], optional, default None
The updated results of the graph. If it's None, then the results will not be updated.
Expand All @@ -160,18 +160,18 @@ def _replace_subgraph(
affected_successors = set()

output_to_node = dict()
removed_nodes = removed_nodes or set()
nodes_to_remove = nodes_to_remove or set()
if graph is not None:
# Add the output key -> node of the subgraph
for node in graph.iter_nodes():
if node in removed_nodes:
if node in nodes_to_remove:
raise ValueError(f"The node {node} is in the removed set")

Check warning on line 168 in mars/optimization/logical/core.py

View check run for this annotation

Codecov / codecov/patch

mars/optimization/logical/core.py#L168

Added line #L168 was not covered by tests
for output in node.outputs:
output_to_node[output.key] = node

for node in removed_nodes:
for node in nodes_to_remove:
for affected_successor in self._graph.iter_successors(node):
if affected_successor not in removed_nodes:
if affected_successor not in nodes_to_remove:
affected_successors.add(affected_successor)
# Check whether affected successors' inputs are in subgraph
for affected_successor in affected_successors:
Expand All @@ -180,7 +180,7 @@ def _replace_subgraph(
raise ValueError(
f"The output {inp} of node {affected_successor} is missing in the subgraph"
)
for node in removed_nodes:
for node in nodes_to_remove:
self._graph.remove_node(node)

if graph is None:
Expand All @@ -200,7 +200,7 @@ def _replace_subgraph(
self._graph.add_edge(pred_node, node)

if new_results is not None:
self._graph.results = new_results.copy()
self._graph.results = list(new_results)

def _add_collapsable_predecessor(self, node: EntityType, predecessor: EntityType):
pred_original = self._records.get_original_entity(predecessor, predecessor)
Expand Down

0 comments on commit c53e623

Please sign in to comment.