Skip to content

Commit 4f7f098

Browse files
authored
Manage list parameter in Excel reform (#1357)
2 parents e70f346 + f1cf9b8 commit 4f7f098

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 44.7.0 [#1357](https://github.com/openfisca/openfisca-core/pull/1357)
4+
5+
#### New features
6+
7+
- Manage list parameter in Excel reform
8+
39
## 44.6.0
410

511
#### Technical changes

openfisca_core/reforms/reform_excel.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ def generate_parameter_tree_values(self, parameter) -> list[tuple[str, float]]:
117117
for threshold, val in zip(value.thresholds, threshold_values):
118118
values.append((f"{name}.{threshold}", val))
119119
else:
120-
values.append((name, value))
120+
if isinstance(value, list):
121+
values.append((name, ", ".join(value)))
122+
else:
123+
values.append((name, value))
121124
return sorted(values, key=lambda v: v[0])
122125

123126
def parameter_data(self) -> list[tuple[str, float]]:
@@ -212,7 +215,16 @@ def modify_parameters(local_parameters: ParameterNode) -> ParameterNode:
212215
)
213216
)
214217
else:
215-
leaf.update(start=date_, value=value)
218+
if "unit" in leaf.metadata and leaf.metadata["unit"] == "list":
219+
if value is None:
220+
leaf.update(start=date_, value=[])
221+
else:
222+
values = [
223+
p.replace(",", "").strip() for p in value.split(" ")
224+
]
225+
leaf.update(start=date_, value=[v for v in values if v])
226+
else:
227+
leaf.update(start=date_, value=value)
216228

217229
for leaf, threshold in params_with_thresholds.values():
218230
sorted_brackets = [v[1] for v in sorted(threshold, key=lambda x: x[0])]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484

8585
setup(
8686
name="OpenFisca-Core",
87-
version="44.6.0",
87+
version="44.7.0",
8888
author="OpenFisca Team",
8989
author_email="contact@openfisca.org",
9090
classifiers=[

0 commit comments

Comments
 (0)