@@ -83,6 +83,7 @@ def __init__(self, **kwargs: dict):
8383 parameter = Parameter (
8484 id = self .id + "-" + param_node .name ,
8585 name = param_node .name ,
86+ label = param_node .metadata .get ("label" , param_node .name ),
8687 tax_benefit_model_version = self ,
8788 description = param_node .description ,
8889 data_type = type (
@@ -152,77 +153,72 @@ def run(self, simulation: "Simulation") -> "Simulation":
152153 )
153154 modifier (microsim )
154155
155- # Allow custom variable selection, or use defaults
156- if simulation .variables is not None :
157- entity_variables = simulation .variables
158- else :
159- # Default comprehensive variable set
160- entity_variables = {
161- "person" : [
162- # IDs and weights
163- "person_id" ,
164- "benunit_id" ,
165- "household_id" ,
166- "person_weight" ,
167- # Demographics
168- "age" ,
169- "gender" ,
170- "is_adult" ,
171- "is_SP_age" ,
172- "is_child" ,
173- # Income
174- "employment_income" ,
175- "self_employment_income" ,
176- "pension_income" ,
177- "private_pension_income" ,
178- "savings_interest_income" ,
179- "dividend_income" ,
180- "property_income" ,
181- "total_income" ,
182- "earned_income" ,
183- # Benefits
184- "universal_credit" ,
185- "child_benefit" ,
186- "pension_credit" ,
187- "income_support" ,
188- "working_tax_credit" ,
189- "child_tax_credit" ,
190- # Tax
191- "income_tax" ,
192- "national_insurance" ,
193- ],
194- "benunit" : [
195- # IDs and weights
196- "benunit_id" ,
197- "benunit_weight" ,
198- # Structure
199- "family_type" ,
200- # Income and benefits
201- "universal_credit" ,
202- "child_benefit" ,
203- "working_tax_credit" ,
204- "child_tax_credit" ,
205- ],
206- "household" : [
207- # IDs and weights
208- "household_id" ,
209- "household_weight" ,
210- # Income measures
211- "household_net_income" ,
212- "hbai_household_net_income" ,
213- "equiv_hbai_household_net_income" ,
214- "household_market_income" ,
215- "household_gross_income" ,
216- # Benefits and tax
217- "household_benefits" ,
218- "household_tax" ,
219- "vat" ,
220- # Housing
221- "rent" ,
222- "council_tax" ,
223- "tenure_type" ,
224- ],
225- }
156+ entity_variables = {
157+ "person" : [
158+ # IDs and weights
159+ "person_id" ,
160+ "benunit_id" ,
161+ "household_id" ,
162+ "person_weight" ,
163+ # Demographics
164+ "age" ,
165+ "gender" ,
166+ "is_adult" ,
167+ "is_SP_age" ,
168+ "is_child" ,
169+ # Income
170+ "employment_income" ,
171+ "self_employment_income" ,
172+ "pension_income" ,
173+ "private_pension_income" ,
174+ "savings_interest_income" ,
175+ "dividend_income" ,
176+ "property_income" ,
177+ "total_income" ,
178+ "earned_income" ,
179+ # Benefits
180+ "universal_credit" ,
181+ "child_benefit" ,
182+ "pension_credit" ,
183+ "income_support" ,
184+ "working_tax_credit" ,
185+ "child_tax_credit" ,
186+ # Tax
187+ "income_tax" ,
188+ "national_insurance" ,
189+ ],
190+ "benunit" : [
191+ # IDs and weights
192+ "benunit_id" ,
193+ "benunit_weight" ,
194+ # Structure
195+ "family_type" ,
196+ # Income and benefits
197+ "universal_credit" ,
198+ "child_benefit" ,
199+ "working_tax_credit" ,
200+ "child_tax_credit" ,
201+ ],
202+ "household" : [
203+ # IDs and weights
204+ "household_id" ,
205+ "household_weight" ,
206+ # Income measures
207+ "household_net_income" ,
208+ "hbai_household_net_income" ,
209+ "equiv_hbai_household_net_income" ,
210+ "household_market_income" ,
211+ "household_gross_income" ,
212+ # Benefits and tax
213+ "household_benefits" ,
214+ "household_tax" ,
215+ "vat" ,
216+ # Housing
217+ "rent" ,
218+ "council_tax" ,
219+ "tenure_type" ,
220+ ],
221+ }
226222
227223 data = {
228224 "person" : pd .DataFrame (),
@@ -247,6 +243,7 @@ def run(self, simulation: "Simulation") -> "Simulation":
247243 )
248244
249245 simulation .output_dataset = PolicyEngineUKDataset (
246+ id = simulation .id ,
250247 name = dataset .name ,
251248 description = dataset .description ,
252249 filepath = str (
@@ -262,7 +259,23 @@ def run(self, simulation: "Simulation") -> "Simulation":
262259 ),
263260 )
264261
262+ def save (self , simulation : "Simulation" ):
263+ """Save the simulation's output dataset."""
265264 simulation .output_dataset .save ()
266265
266+ def load (self , simulation : "Simulation" ):
267+ """Load the simulation's output dataset."""
268+ simulation .output_dataset = PolicyEngineUKDataset (
269+ id = simulation .id ,
270+ name = simulation .dataset .name ,
271+ description = simulation .dataset .description ,
272+ filepath = str (
273+ Path (simulation .dataset .filepath ).parent
274+ / (simulation .id + ".h5" )
275+ ),
276+ year = simulation .dataset .year ,
277+ is_output_dataset = True ,
278+ )
279+
267280
268281uk_latest = PolicyEngineUKLatest ()
0 commit comments