Skip to content

Commit

Permalink
Adapte test
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainipp committed Jan 25, 2024
1 parent f544a94 commit 062e51a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions openfisca_survey_manager/tests/test_calibration.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import pytest


from openfisca_core.tools import assert_near

from openfisca_core import periods

from openfisca_survey_manager.tests.test_scenario import create_randomly_initialized_survey_scenario
from openfisca_survey_manager.tests.test_scenario import generate_input_input_dataframe_by_entity
from openfisca_survey_manager.calibration import Calibration

from openfisca_survey_manager import default_config_files_directory
from openfisca_survey_manager.scenarios.abstract_scenario import AbstractSurveyScenario
from openfisca_survey_manager.tests import tax_benefit_system

def test_calibration_variable_entity_is_weight_entity():
survey_scenario = create_randomly_initialized_survey_scenario(collection=None)
Expand Down Expand Up @@ -86,7 +89,7 @@ def test_simulation_calibration_variable_entity_is_weight_entity():

def test_simulation_calibration_input_from_data():
input_data_frame_by_entity = generate_input_input_dataframe_by_entity(
nb_persons, nb_groups, salary_max_value, rent_max_value)
10, 5, 5000, 1000)
survey_scenario = AbstractSurveyScenario()
weight_variable_by_entity = {
"person": "person_weight",
Expand All @@ -102,14 +105,15 @@ def test_simulation_calibration_input_from_data():
survey_scenario.period = 2017
survey_scenario.used_as_input_variables = ['salary', 'rent', 'household_weight']
period = periods.period('2017-01')
target_rent_aggregate = 200000

data = {
'input_data_frame_by_entity_by_period': {
period: input_data_frame_by_entity
},
'config_files_directory': default_config_files_directory
}
calibration_kwargs = {'target_margins_by_variable':{'rent': target_rent_aggregate}, 'target_entity_count':300, 'parameters':{'method':'logit', 'up':4, 'invlo':4}}
calibration_kwargs = {'target_margins_by_variable': {'rent': target_rent_aggregate}, 'target_entity_count': 300, 'parameters': {'method': 'logit', 'up': 4, 'invlo': 4}}
survey_scenario.set_weight_variable_by_entity(weight_variable_by_entity)
assert survey_scenario.weight_variable_by_entity == weight_variable_by_entity
survey_scenario.init_from_data(data = data, calibration_kwargs=calibration_kwargs)
Expand Down

0 comments on commit 062e51a

Please sign in to comment.