diff --git a/decoimpact/business/entities/rules/axis_filter_rule.py b/decoimpact/business/entities/rules/axis_filter_rule.py index bddcfc42..c2bced14 100644 --- a/decoimpact/business/entities/rules/axis_filter_rule.py +++ b/decoimpact/business/entities/rules/axis_filter_rule.py @@ -58,13 +58,13 @@ def execute(self, value_array: _xr.DataArray, logger: ILogger) -> _xr.DataArray: Returns: float: 2D variable """ - + if self._axis_name not in value_array.dims: message = f"""Layer name is not in dim names \ [{value_array.dims}] layer_name [{self._axis_name}]""" logger.log_error(message) raise IndexError(message) - + if not ( self._layer_number >= 0 and self._layer_number <= len(getattr(value_array, self._axis_name)) @@ -74,4 +74,4 @@ def execute(self, value_array: _xr.DataArray, logger: ILogger) -> _xr.DataArray: logger.log_error(message) raise IndexError(message) - return value_array.isel({self._axis_name: self._layer_number - 1}) \ No newline at end of file + return value_array.isel({self._axis_name: self._layer_number - 1}) diff --git a/decoimpact/business/workflow/model_builder.py b/decoimpact/business/workflow/model_builder.py index 44935a7f..cecac91c 100644 --- a/decoimpact/business/workflow/model_builder.py +++ b/decoimpact/business/workflow/model_builder.py @@ -100,7 +100,7 @@ def _create_rule(rule_data: IRuleData) -> IRule: rule_data.layer_number, rule_data.output_variable, ) - + if isinstance(rule_data, IAxisFilterRuleData): return AxisFilterRule( rule_data.name, diff --git a/decoimpact/data/api/i_axis_filter_rule_data.py b/decoimpact/data/api/i_axis_filter_rule_data.py index 1b49d202..33744026 100644 --- a/decoimpact/data/api/i_axis_filter_rule_data.py +++ b/decoimpact/data/api/i_axis_filter_rule_data.py @@ -30,8 +30,8 @@ def input_variable(self) -> str: @abstractmethod def layer_number(self) -> int: """Property for the layer number""" - + @property @abstractmethod def axis_name(self) -> str: - """Property for the dim name""" \ No newline at end of file + """Property for the dim name""" diff --git a/decoimpact/data/entities/axis_filter_rule_data.py b/decoimpact/data/entities/axis_filter_rule_data.py index 4ba0a584..43fdc40c 100644 --- a/decoimpact/data/entities/axis_filter_rule_data.py +++ b/decoimpact/data/entities/axis_filter_rule_data.py @@ -42,9 +42,8 @@ def input_variable(self) -> str: def layer_number(self) -> int: """Property for the layer number""" return self._layer_number - + @property def axis_name(self) -> str: """Property for the dimension name""" return self._axis_name - diff --git a/decoimpact/data/parsers/parser_axis_filter_rule.py b/decoimpact/data/parsers/parser_axis_filter_rule.py index 32b0967b..88145810 100644 --- a/decoimpact/data/parsers/parser_axis_filter_rule.py +++ b/decoimpact/data/parsers/parser_axis_filter_rule.py @@ -46,7 +46,7 @@ def parse_dict(self, dictionary: Dict[str, Any], logger: ILogger) -> IRuleData: f"received a {type(axis_name)}: {axis_name}" ) raise ValueError(message) - + layer_number = get_dict_element("layer_number", dictionary) if not isinstance(layer_number, int): message = ( @@ -57,6 +57,6 @@ def parse_dict(self, dictionary: Dict[str, Any], logger: ILogger) -> IRuleData: output_variable_name = get_dict_element("output_variable", dictionary) return AxisFilterRuleData( - name, layer_number, axis_name, input_variable_name, + name, layer_number, axis_name, input_variable_name, output_variable_name, description )