Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Jul 25, 2024
1 parent 7765a5d commit 2eb148a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def extract_single_value(variable):
if np.issubdtype(variable.values.dtype, np.datetime64):
if len(shape) == 0:
return to_datetime(variable.values) # Convert to python datetime
assert False, (shape, variable.values)
assert False, (shape, variable.values[:2])

if np.issubdtype(variable.values.dtype, np.timedelta64):
if len(shape) == 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ def _get(self, key, **kwargs):
else:
return kwargs.get("default", None)

key = self._mapping.from_user(key)
if self._mapping is not None:
key = self._mapping.from_user(key)

return super()._get(key, **kwargs)


Expand Down
6 changes: 3 additions & 3 deletions src/anemoi/datasets/create/functions/sources/xarray/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def __init__(self, date_coordinate, step_coordinate):
self.step_coordinate = step_coordinate

def fill_time_metadata(self, time, metadata):
metadata["date"] = self.date_coordinate.single_value.strftime("%Y%m%d")
metadata["time"] = self.date_coordinate.single_value.strftime("%H%M")
hours = self.step_coordinate.total_seconds() / 3600
metadata["date"] = time.strftime("%Y%m%d")
metadata["time"] = time.strftime("%H%M")
hours = metadata[self.step_coordinate.name].total_seconds() / 3600
assert int(hours) == hours
metadata["step"] = int(hours)

0 comments on commit 2eb148a

Please sign in to comment.