Skip to content

Commit 8861ea0

Browse files
authored
Add min computation period (#1329)
2 parents 47927e9 + 49f6f94 commit 8861ea0

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

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

3+
### 43.3.8 [#1329](https://github.com/openfisca/openfisca-core/pull/1329)
4+
5+
#### New features
6+
7+
- Add a parameter `start_computation_period` in simulation : if this parameter is not None, the simulation return the default value for all variable calculate before this period. The aim is to avoid computation of variables for period before the input variables period.
8+
39
### 43.3.7 [#1328](https://github.com/openfisca/openfisca-core/pull/1328)
410

511
#### Technical changes

openfisca_core/simulations/simulation.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def __init__(
5959
self.max_spiral_loops: int = 1
6060
self.memory_config = None
6161
self._data_storage_dir = None
62+
self.start_computation_period = None
6263

6364
@property
6465
def trace(self):
@@ -144,6 +145,13 @@ def _calculate(self, variable_name: str, period: periods.Period):
144145
array = None
145146

146147
# First, try to run a formula
148+
if self.start_computation_period is not None:
149+
if not isinstance(self.start_computation_period, periods.Period):
150+
self.start_computation_period = periods.period(
151+
self.start_computation_period
152+
)
153+
if period < self.start_computation_period:
154+
return holder.default_array()
147155
try:
148156
self._check_for_cycle(variable.name, period)
149157
array = self._run_formula(variable, population, period)

setup.py

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

7171
setup(
7272
name="OpenFisca-Core",
73-
version="43.3.7",
73+
version="43.3.8",
7474
author="OpenFisca Team",
7575
author_email="[email protected]",
7676
classifiers=[

0 commit comments

Comments
 (0)