Skip to content

Commit 358feb1

Browse files
authored
Merge pull request #5 from CU-ESIIL/codex/fix-zscore_over_time_basic-assertion-error
Fix z-score dimension handling
2 parents 7b71866 + 6d84b83 commit 358feb1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

code/climate_cube_math/stats/anomalies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def zscore_over_time(
1818
eps = STD_EPS if std_eps is None else std_eps
1919
mean = da.mean(dim=dim, skipna=True)
2020
std = da.std(dim=dim, skipna=True)
21-
valid_std = std > eps
21+
valid_std = (std > eps).broadcast_like(da)
2222
z = xr.where(valid_std, (da - mean) / std, np.nan)
2323
# Keep the original dimension ordering so callers don't have to
2424
# defensively transpose results. xarray broadcasting can sometimes

0 commit comments

Comments
 (0)