Skip to content

Commit

Permalink
fix spurious error
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Apr 16, 2024
1 parent 1e87ea9 commit 58b21bb
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions ai_models/outputs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,21 @@ def output(self):
)

def write(self, data, *args, check=False, **kwargs):

try:
handle, path = self.output.write(data, *args, **kwargs)

except Exception:
if np.isnan(data).any():
raise ValueError(
f"NaN values found in field. args={args} kwargs={kwargs}"
)
if np.isinf(data).any():
raise ValueError(
f"Infinite values found in field. args={args} kwargs={kwargs}"
)
raise
if data is not None:
if np.isnan(data).any():
raise ValueError(
f"NaN values found in field. args={args} kwargs={kwargs}"
)
if np.isinf(data).any():
raise ValueError(
f"Infinite values found in field. args={args} kwargs={kwargs}"
)
raise

if check:
# Check that the GRIB keys are as expected
Expand Down Expand Up @@ -88,13 +90,13 @@ def __init__(self, owner, output, hindcast_reference_year, **kwargs):
def write(self, *args, **kwargs):
if "hdate" in kwargs:
warnings.warn(
f"Ignoring hdate='{kwargs['hdate']}' in write call", stacklevel=3
f"Ignoring hdate='{kwargs['hdate']}' in HindcastReLabel", stacklevel=3
)
kwargs.pop("hdate")

if "date" in kwargs:
warnings.warn(
f"Ignoring date='{kwargs['date']}' in write call", stacklevel=3
f"Ignoring date='{kwargs['date']}' in HindcastReLabel", stacklevel=3
)
kwargs.pop("date")

Expand Down

0 comments on commit 58b21bb

Please sign in to comment.