From fa38af668de9683a9cd1d3e991a9b1b2caff81c0 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Thu, 24 Oct 2024 12:01:05 +0100 Subject: [PATCH] Add safety check --- policyengine_core/simulations/simulation.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/policyengine_core/simulations/simulation.py b/policyengine_core/simulations/simulation.py index 156bb087..a18312c2 100644 --- a/policyengine_core/simulations/simulation.py +++ b/policyengine_core/simulations/simulation.py @@ -1551,9 +1551,12 @@ def subsample( self.build_from_dataset() # Ensure the baseline branch has the new data. - baseline_tax_benefit_system = self.baseline.tax_benefit_system - self.branches["baseline"] = self.clone() - self.branches["tax_benefit_system"] = baseline_tax_benefit_system + 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