diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c88ef64..681af78e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ # Changelog + +### 3.3.2 [#319](https://github.com/openfisca/openfisca-survey-manager/pull/315) + +* Technical changes + - Transform input arrays of Enums variables in EnumArray type to improve computation speed due to changes in Openfisca-core 42 + ### 2.3.1 [#300](https://github.com/openfisca/openfisca-survey-manager/pull/300) * New features diff --git a/openfisca_survey_manager/simulations.py b/openfisca_survey_manager/simulations.py index b42f5b95..e700a39b 100644 --- a/openfisca_survey_manager/simulations.py +++ b/openfisca_survey_manager/simulations.py @@ -14,7 +14,7 @@ from openfisca_core import periods from openfisca_core.memory_config import MemoryConfig -from openfisca_core.indexed_enums import Enum +from openfisca_core.indexed_enums import (Enum, EnumArray) from openfisca_core.periods import ETERNITY, MONTH, YEAR from openfisca_core.types import Array, CoreEntity as Entity, Period, TaxBenefitSystem from openfisca_core.simulations import Simulation @@ -1094,6 +1094,10 @@ def init_variable_in_entity(simulation: Simulation, entity, variable_name, serie array = series.values.astype(variable.dtype) np_array = np.array(array, dtype = variable.dtype) + + if (variable.value_type == Enum) and (np.issubdtype(series.values.dtype, np.integer) or np.issubdtype(series.values.dtype, float)): + np_array = EnumArray(np_array, variable.possible_values) + if variable.definition_period == YEAR and period.unit == MONTH: # Some variables defined for a year are present in month/quarter dataframes # Cleaning the dataframe would probably be better in the long run diff --git a/setup.py b/setup.py index 89d0c42f..57a99426 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ setup( name = 'OpenFisca-Survey-Manager', - version = '2.3.1', + version = '2.3.2', author = 'OpenFisca Team', author_email = 'contact@openfisca.fr', classifiers = [classifier for classifier in classifiers.split('\n') if classifier],