Skip to content

Commit

Permalink
Add weeks to holders
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauko Quiroga committed Mar 11, 2021
1 parent c557909 commit dc4de48
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion openfisca_core/holders.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from openfisca_core.data_storage import InMemoryStorage, OnDiskStorage
from openfisca_core.errors import PeriodMismatchError
from openfisca_core.indexed_enums import Enum
from openfisca_core.periods import MONTH, YEAR, ETERNITY
from openfisca_core.periods import WEEK, MONTH, YEAR, ETERNITY
from openfisca_core.tools import eval_expression

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -209,6 +209,10 @@ def _set(self, period, value):
if self.variable.definition_period != ETERNITY:
if period is None:
raise ValueError('A period must be specified to set values, except for variables with ETERNITY as as period_definition.')

if self.variable.definition_period == WEEK:
period = periods.period(f"{WEEK}:{period}")

if (self.variable.definition_period != period.unit or period.size > 1):
name = self.variable.name
period_size_adj = f'{period.unit}' if (period.size == 1) else f'{period.size}-{period.unit}s'
Expand Down

0 comments on commit dc4de48

Please sign in to comment.