Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve issue calmar target_entity_count #316

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog

### 3.3.2 [#319](https://github.com/openfisca/openfisca-survey-manager/pull/315)
### 2.3.3 [#316](https://github.com/openfisca/openfisca-survey-manager/pull/315)

* Technical changes
- Solve an issue caused by #299 when there is a target_entity_count without variables of the same entity.
- Correct the CHANGELOG which had two errors.


### 2.3.2 [#315](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
Expand All @@ -11,7 +18,7 @@
- Add a new distance function method, the hyperbolic sinus. It allows to cap the weight ratio with a one dimensionnal parametring, and with less computation issues than with the logit method.
- It is described in Calmar 2 documentation

## 2.3.0 [#308](https://github.com/openfisca/openfisca-survey-manager/pull/308)
## 2.3.0 [#299](https://github.com/openfisca/openfisca-survey-manager/pull/299)

* New features
- Allows for calibration of variables defined in two different entities ; it requires that one is included in the other (ex : individuals and fiscal household : each individual is in only one fiscal household). To use it, a variable identifying in the smaller entity the identifier of the larger one is needed (the name must be given in parameter "id_variable_link").
Expand Down
7 changes: 5 additions & 2 deletions openfisca_survey_manager/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def __init__(self, simulation, target_margins, period, target_entity_count = Non
variable_instance_by_variable_name[variable].entity.key
for variable in margin_variables
)
if entity is not None:
entities.add(entity)
self.entities = list(entities)

if len(entities) == 0:
Expand Down Expand Up @@ -242,13 +244,14 @@ def set_calibrated_weights(self):
simulation = self.simulation
simulation.set_input(self.weight_name, period, self.weight)
for weight_name in simulation.weight_variable_by_entity.values():
weight_variable = simulation.tax_benefit_system.variables[weight_name]
if weight_name == self.weight_name:
weight_variable = simulation.tax_benefit_system.variables[weight_name]
weight_variable.unit = "base_weight" # The weight variable is flagged as the one that have changed
if weight_variable.formulas:
weight_variable.formulas = [] # The weight variable becomes an input variable after it changes with calibration
# Delete other entites already computed weigths
# to ensure that this weights a recomputed if they derive from
# the calibrated weight variable
weight_variable = simulation.tax_benefit_system.variables[weight_name]
if weight_variable.formulas:
simulation.delete_arrays(weight_variable.name, period)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

setup(
name = 'OpenFisca-Survey-Manager',
version = '2.3.2',
version = '2.3.3',
author = 'OpenFisca Team',
author_email = 'contact@openfisca.fr',
classifiers = [classifier for classifier in classifiers.split('\n') if classifier],
Expand Down