Skip to content

Commit

Permalink
handle exceptionally rare error
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeitsperre committed Dec 10, 2024
1 parent 2195f08 commit 136a4cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Internal changes
* The `numpydoc` linting tool has been added to the development dependencies, linting checks, and the `pre-commit` configuration. (:pull:`1988`).
* `xclim` now uses a `src` layout for the codebase. Structure-dependent functions, documentation, and build commands have been adapted to reflect these changes. (:pull:`1971`).
* Added a more robust `yamllint` configuration to ensure that all YAML files are linted consistently. (:pull:`1971`).
* Addressed a very rare singular matrix error that can happen in ``test_loess_smoothing_nan``.

CI changes
^^^^^^^^^^
Expand Down
11 changes: 10 additions & 1 deletion tests/test_sdba/test_loess.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import logging

import numpy as np
import pandas as pd
import pytest
Expand Down Expand Up @@ -84,4 +86,11 @@ def test_loess_smoothing_nan(use_dask):

assert out.dims == da.dims
# check that the output is all nan on the axis with nan in the input
assert np.isnan(out.values[0, 0]).all()
try:
assert np.isnan(out.values[0, 0]).all()
except np.linalg.LinAlgError:
msg = (
"This has roughly a 1/50,000,000 chance of occurring. Buy a lottery ticket!"
)
logging.error(msg)
pass

0 comments on commit 136a4cc

Please sign in to comment.