Skip to content

Commit

Permalink
Fix subsampling bug (#297)
Browse files Browse the repository at this point in the history
* Fix Subsample doesn't work with behavioural response simulations #296

* Versioning

* Add safety check
  • Loading branch information
nikhilwoodruff authored Oct 24, 2024
1 parent f280ca5 commit c2d8a7a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: minor
changes:
fixed:
- Bug causing subsample to not work in some situations.
8 changes: 8 additions & 0 deletions policyengine_core/simulations/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,14 @@ def subsample(
# Update the dataset and rebuild the simulation
self.dataset = Dataset.from_dataframe(df, self.dataset.time_period)
self.build_from_dataset()

# Ensure the baseline branch has the new data.
if "baseline" in self.branches:
baseline_tax_benefit_system = self.branches[
"baseline"
].tax_benefit_system
self.branches["baseline"] = self.clone()
self.branches["tax_benefit_system"] = baseline_tax_benefit_system
return self


Expand Down

0 comments on commit c2d8a7a

Please sign in to comment.