Skip to content

Commit 58b21bb

Browse files
committed
fix spurious error
1 parent 1e87ea9 commit 58b21bb

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

ai_models/outputs/__init__.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,21 @@ def output(self):
4747
)
4848

4949
def write(self, data, *args, check=False, **kwargs):
50+
5051
try:
5152
handle, path = self.output.write(data, *args, **kwargs)
5253

5354
except Exception:
54-
if np.isnan(data).any():
55-
raise ValueError(
56-
f"NaN values found in field. args={args} kwargs={kwargs}"
57-
)
58-
if np.isinf(data).any():
59-
raise ValueError(
60-
f"Infinite values found in field. args={args} kwargs={kwargs}"
61-
)
62-
raise
55+
if data is not None:
56+
if np.isnan(data).any():
57+
raise ValueError(
58+
f"NaN values found in field. args={args} kwargs={kwargs}"
59+
)
60+
if np.isinf(data).any():
61+
raise ValueError(
62+
f"Infinite values found in field. args={args} kwargs={kwargs}"
63+
)
64+
raise
6365

6466
if check:
6567
# Check that the GRIB keys are as expected
@@ -88,13 +90,13 @@ def __init__(self, owner, output, hindcast_reference_year, **kwargs):
8890
def write(self, *args, **kwargs):
8991
if "hdate" in kwargs:
9092
warnings.warn(
91-
f"Ignoring hdate='{kwargs['hdate']}' in write call", stacklevel=3
93+
f"Ignoring hdate='{kwargs['hdate']}' in HindcastReLabel", stacklevel=3
9294
)
9395
kwargs.pop("hdate")
9496

9597
if "date" in kwargs:
9698
warnings.warn(
97-
f"Ignoring date='{kwargs['date']}' in write call", stacklevel=3
99+
f"Ignoring date='{kwargs['date']}' in HindcastReLabel", stacklevel=3
98100
)
99101
kwargs.pop("date")
100102

0 commit comments

Comments
 (0)