Skip to content

Commit

Permalink
Explicit refactor with a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
guillett committed Feb 5, 2024
1 parent 287de7b commit d9c8aec
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions openfisca_core/simulations/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,19 @@ def invalidate_cache_entry(self, variable: str, period):
self.invalidated_caches.add(Cache(variable, period))

def invalidate_spiral_variables(self, variable: str):
initial_call_found = False
invalidate_entries = False
# 1. find the initial variable call
# 2. find the next variable call
# 3. invalidate all frame items from there
for frame in self.tracer.stack:
if invalidate_entries:
self.invalidate_cache_entry(str(frame["name"]), frame["period"])
if initial_call_found:
if not invalidate_entries and frame["name"] == variable:
invalidate_entries = True
if invalidate_entries:
self.invalidate_cache_entry(str(frame["name"]), frame["period"])
elif frame["name"] == variable:
invalidate_entries = True
initial_call_found = True

# ----- Methods to access stored values ----- #

Expand Down

0 comments on commit d9c8aec

Please sign in to comment.