Skip to content

Commit 459a79a

Browse files
committed
Fix: set uncertainty to NaN
1 parent 376a9a4 commit 459a79a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

kaleidoscope/operators/collectop.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
from ..logger import get_logger
2222

2323

24+
def _std(x: da.Array) -> da.Array:
25+
"""Returns the standard deviation."""
26+
return da.where(
27+
da.count_nonzero(da.isfinite(x), axis=0) > 0,
28+
da.nanstd(x, axis=0),
29+
np.nan,
30+
)
31+
32+
2433
class CollectOp(Operator):
2534
"""The collect operator."""
2635

@@ -56,7 +65,7 @@ def run(self, source: Dataset) -> Dataset: # noqa: D102
5665
if v_unc in target:
5766
continue
5867
get_logger().info(f"starting graph for variable: {v_unc}")
59-
x_unc = da.nanstd(decode(subset[v].data, x.attrs), axis=0)
68+
x_unc = _std(decode(subset[v].data, x.attrs))
6069
get_logger().info(f"finished graph for variable: {v_unc}")
6170
target[v_unc] = DataArray(
6271
data=encode(x_unc, x.attrs, x.dtype),

0 commit comments

Comments
 (0)