Exemple #1
0
def test_canonicalize_period_keys(persons):
    persons_json = {'Alicia': {'salary': {'year:2018-01': 100}}}
    simulation_builder = SimulationBuilder()
    simulation_builder.add_person_entity(persons, persons_json)
    population = Population(persons)
    simulation_builder.finalize_variables_init(population)
    tools.assert_near(
        population.get_holder('salary').get_array('2018-12'), [100])
Exemple #2
0
def test_finalize_person_entity(persons):
    persons_json = {'Alicia': {'salary': {'2018-11': 3000}}, 'Javier': {}}
    simulation_builder = SimulationBuilder()
    simulation_builder.add_person_entity(persons, persons_json)
    population = Population(persons)
    simulation_builder.finalize_variables_init(population)
    tools.assert_near(
        population.get_holder('salary').get_array('2018-11'), [3000, 0])
    assert population.count == 2
    assert population.ids == ['Alicia', 'Javier']
Exemple #3
0
def test_finalize_households(tax_benefit_system):
    simulation = Simulation(tax_benefit_system,
                            tax_benefit_system.instantiate_entities())
    simulation_builder = SimulationBuilder()
    simulation_builder.add_group_entity(
        'persons', ['Alicia', 'Javier', 'Sarah', 'Tom'],
        simulation.household.entity, {
            'Household_1': {
                'parents': ['Alicia', 'Javier']
            },
            'Household_2': {
                'parents': ['Tom'],
                'children': ['Sarah']
            },
        })
    simulation_builder.finalize_variables_init(simulation.household)
    tools.assert_near(simulation.household.members_entity_id, [0, 0, 1, 1])
    tools.assert_near(simulation.persons.has_role(entities.Household.PARENT),
                      [True, True, False, True])