Skip to content

Commit

Permalink
Revert "Fix default arguments = [] change to None"
Browse files Browse the repository at this point in the history
This reverts commit 9edf5c7.
  • Loading branch information
mKlapwijk committed Nov 21, 2023
1 parent 46abc29 commit c3dc21b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions decoimpact/business/entities/rules/multiply_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"""

from datetime import datetime as _dt
from typing import List, Optional
from typing import List

import numpy as _np
import xarray as _xr
Expand All @@ -31,7 +31,7 @@ def __init__(
input_variable_names: List[str],
multipliers: List[List[float]],
output_variable_name: str = "output",
date_range: Optional[List[List[str]]] = None,
date_range: List[List[str]] = [],
description: str = "",
):
super().__init__(name, input_variable_names, output_variable_name, description)
Expand All @@ -44,7 +44,7 @@ def multipliers(self) -> List[List[float]]:
return self._multipliers

@property
def date_range(self) -> Optional[List[List[str]]]:
def date_range(self) -> List[List[str]]:
"""Date range property"""
return self._date_range

Expand All @@ -64,7 +64,7 @@ def execute(self, value_array: _xr.DataArray, logger: ILogger) -> _xr.DataArray:
old_dr = _xr.DataArray(value_array)
new_dr = _xr.full_like(old_dr, _np.nan)
for (index, _mp) in enumerate(result_multipliers):
if self.date_range is not None:
if len(self.date_range) != 0:
# Date is given in DD-MM, convert to MM-DD for comparison
start = self._convert_datestr(self.date_range[index][0])
end = self._convert_datestr(self.date_range[index][1])
Expand Down
4 changes: 2 additions & 2 deletions decoimpact/data/entities/multiply_rule_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"""

from typing import List, Optional
from typing import List

from decoimpact.data.api.i_multiply_rule_data import IMultiplyRuleData
from decoimpact.data.entities.rule_data import RuleData
Expand All @@ -28,7 +28,7 @@ def __init__(
input_variable: str,
output_variable: str = "output",
description: str = "",
date_range: Optional[List[List[str]]] = None,
date_range: List[List[str]] = [],
):
super().__init__(name, output_variable, description)
self._input_variable = input_variable
Expand Down
4 changes: 2 additions & 2 deletions tests/business/entities/rules/test_multiply_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

from unittest.mock import Mock

import numpy as _np
import xarray as _xr
import numpy as _np

from decoimpact.business.entities.rules.multiply_rule import MultiplyRule
from decoimpact.crosscutting.i_logger import ILogger
Expand All @@ -29,7 +29,7 @@ def test_create_multiply_rule_should_set_defaults():
assert rule.input_variable_names == ["foo"]
assert rule.output_variable_name == "output"
assert rule.multipliers == [[0.5, 3.0]]
assert rule.date_range == None
assert rule.date_range == []
assert isinstance(rule, MultiplyRule)


Expand Down

0 comments on commit c3dc21b

Please sign in to comment.