Skip to content

Commit 7720c1d

Browse files
committed
fix(denoise): work around dask 2024.12 passing removed interpolation kwarg to numpy 2.x
Dask 2024.12.1's _nanquantile_1d_or_missing passes interpolation=None to np.nanquantile, which was removed in numpy 2.x. Use skipna=False to avoid the nanquantile code path entirely, filling NaN values before computing the quantile instead.
1 parent 3563be2 commit 7720c1d

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

oceanstream/echodata/denoise/background_noise.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,13 @@ def background_noise_mask(
190190
if depth_stat == "min":
191191
noise_1d_db = binned_db.min(dim=range_dim, skipna=True)
192192
elif depth_stat == "quantile":
193-
# Use numpy directly — xarray's skipna=True path calls
194-
# np.nanquantile with the deprecated ``interpolation`` kwarg
195-
# which was removed in numpy 2.x.
196-
noise_1d_db = binned_db.quantile(
197-
depth_quantile, dim=range_dim, method="linear"
193+
# Use skipna=False to avoid the xarray → dask → np.nanquantile
194+
# code path where dask 2024.12.x passes the removed 'interpolation'
195+
# kwarg to numpy 2.x's nanquantile. We drop NaN slices ourselves
196+
# before computing the quantile.
197+
_binned = binned_db.fillna(0.0) if binned_db.isnull().any() else binned_db
198+
noise_1d_db = _binned.quantile(
199+
depth_quantile, dim=range_dim, method="linear", skipna=False
198200
)
199201
if "quantile" in noise_1d_db.dims:
200202
noise_1d_db = noise_1d_db.squeeze("quantile", drop=True)

0 commit comments

Comments
 (0)