def test_input_with_wrong_period(tax_benefit_system): year = str(PERIOD.this_year) variables = {"basic_income": {year: 12000}} simulation_builder = SimulationBuilder() simulation_builder.set_default_period(PERIOD) with pytest.raises(ValueError): simulation_builder.build_from_variables(tax_benefit_system, variables)
def simulation(tax_benefit_system, month): simulation_builder = SimulationBuilder() simulation_builder.default_period = month simulation = simulation_builder.build_from_variables( tax_benefit_system, {'choice': numpy.random.randint(2, size=1000) + 1}) simulation.debug = True return simulation
def new_simulation(self, debug=False, opt_out_cache=False, use_baseline=False, trace=False): # Legacy from scenarios, used in reforms tax_benefit_system = self.tax_benefit_system if use_baseline: while True: baseline = tax_benefit_system.baseline if baseline is None: break tax_benefit_system = baseline builder = SimulationBuilder() if self.attributes: variables = self.attributes.get('input_variables') or {} period = self.attributes.get('period') builder.set_default_period(period) simulation = builder.build_from_variables( tax_benefit_system, variables) else: builder.set_default_period(self.period) simulation = builder.build_from_entities( tax_benefit_system, self.dict) simulation.trace = trace simulation.debug = debug simulation.opt_out_cache = opt_out_cache return simulation