Skip to content

Commit

Permalink
feat[DEI-45]: fix based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
IoannaMi committed Oct 31, 2023
1 parent 916ec80 commit 3cc357c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
8 changes: 0 additions & 8 deletions decoimpact/business/entities/rules/rolling_statistics_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,13 @@ def _perform_operation(
DataArray: Values of operation type
"""

# derived from this stackoverflow answer:
# https://stackoverflow.com/questions/76556088/rolling-timedelta-temporal-window-with-xarray

result_array = _cp.deepcopy(values)
result_array = result_array.where(False, _np.nan)

if time_scale == "H":
operation_time_delta = _dt.timedelta(hours=period)
elif time_scale == "D":
operation_time_delta = _dt.timedelta(days=period)
# elif time_scale == "M":
# operation_time_delta = _dt.timedelta(months=period)
# elif time_scale == "Y":
# operation_time_delta = _dt.timedelta(years=period)
# NB 'months' and 'years' are not supported this way
else:
logger.log_error(f"Invalid time scale provided : '{time_scale}'.")

Expand Down
3 changes: 1 addition & 2 deletions decoimpact/business/utils/dataset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,11 @@ def get_time_dimension_name(variable: _xr.DataArray, logger: ILogger) -> str:
str: time dimension name
"""


for dim in variable.dims:
dim_values = variable[dim]
if dim_values.dtype.name == "datetime64[ns]":
return str(dim)

message = f"No time dimension found for {variable.name}"
logger.log_error(message)
raise ValueError(message)
raise ValueError(message)

0 comments on commit 3cc357c

Please sign in to comment.