Skip to content

Commit

Permalink
make slicing work better with memoization
Browse files Browse the repository at this point in the history
  • Loading branch information
smacke committed Dec 2, 2023
1 parent ba008a9 commit 49a346d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/ipyflow/shell/interactiveshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ def _handle_memoization(self) -> None:
cell.memoized_executions = prev_cell.memoized_executions
prev_cell.memoized_executions = []
if cell.skipped_due_to_memoization_ctr > 0:
cell.to_ast(override=prev_cell.to_ast())
prev_cell = Cell.at_counter(cell.skipped_due_to_memoization_ctr)
assert prev_cell is not None
for parent, syms in prev_cell.static_parents.items():
Expand All @@ -579,8 +580,14 @@ def _handle_memoization(self) -> None:
for parent, syms in prev_cell.dynamic_parents.items():
with dynamic_slicing_context():
cell.add_parent_edges(parent, syms)
for stmt, prev_stmt in zip(cell.statements(), prev_cell.statements()):
for parent, syms in prev_stmt.static_parents.items():
with static_slicing_context():
stmt.add_parent_edges(parent, syms)
for parent, syms in prev_stmt.dynamic_parents.items():
with dynamic_slicing_context():
stmt.add_parent_edges(parent, syms)
cell.captured_output = prev_cell.captured_output
cell.to_ast(override=prev_cell.to_ast())
elif cell.is_memoized:
cell._maybe_memoize_params()

Expand Down

0 comments on commit 49a346d

Please sign in to comment.