Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Feb 18, 2024
1 parent 4df3e14 commit ca4e947
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions ecml_tools/create/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,12 @@ def __init__(self, context, action_path, dates):
assert isinstance(context, Context), type(context)

assert action_path is None or isinstance(action_path, list), action_path
action_path = tuple(action_path or [])

self.context = context
self._coords = Coords(self)
self._dates = dates
self.action_path = action_path or []
self.action_path = action_path
if action_path is not None:
context.register_reference(action_path, self)

Expand Down Expand Up @@ -464,7 +465,10 @@ def datasource(self):
raise

def __repr__(self):
return f"{self.action.name}({shorten(self.dates)})"
try:
return f"{self.action.name}({shorten(self.dates)})"
except Exception:
return f"{self.__class__.__name__}(unitialised)"

@property
def function(self):
Expand Down Expand Up @@ -519,14 +523,14 @@ def _trace_select(self, dates):

class ConcatResult(Result):
def __init__(self, context, action_path, results):
super().__init__(context, dates=None)
super().__init__(context, action_path, dates=None)
self.results = [r for r in results if not r.empty]

@cached_property
@check_references
@trace_datasource
def datasource(self):
ds = EmptyResult(self.context, self.dates).datasource
ds = EmptyResult(self.context, None, self.dates).datasource
for i in self.results:
ds += i.datasource
assert_is_fieldset(ds), i
Expand Down Expand Up @@ -700,7 +704,7 @@ def select(self, dates):

class DateAction(Action):
def __init__(self, context, action_path, **kwargs):
super().__init__(context, **kwargs)
super().__init__(context, action_path, **kwargs)

datesconfig = {}
subconfig = {}
Expand All @@ -717,7 +721,7 @@ def __init__(self, context, action_path, **kwargs):
def select(self, dates):
newdates = self._dates.intersect(dates)
if newdates.empty():
return EmptyResult(self.context, dates=newdates)
return EmptyResult(self.context, None, newdates)
return self.content.select(newdates)

def __repr__(self):
Expand Down
1 change: 1 addition & 0 deletions tests/_test_create.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
# (C) Copyright 2023 European Centre for Medium-Range Weather Forecasts.
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
Expand Down

0 comments on commit ca4e947

Please sign in to comment.