Skip to content

Commit e94838a

Browse files
committed
dev
1 parent c6ef954 commit e94838a

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

cf/data/collapse/dask_collapse.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,16 @@ def cf_sample_size_chunk(x, dtype="i8", computing_meta=False, **kwargs):
859859

860860
x = cfdm_to_memory(x)
861861
if np.ma.isMA(x):
862-
N = chunk.sum(np.ones_like(x, dtype=dtype), **kwargs)
862+
# Note: We're not using `np.ones_like` here (like we used to
863+
# for numpy<2.0.0) because numpy currently
864+
# (numpy==2.2.3) has a bug that produces a
865+
# RuntimeWarning: "numpy/ma/core.py:502: RuntimeWarning:
866+
# invalid value encountered in cast fill_value =
867+
# np.asarray(fill_value, dtype=ndtype)". See
868+
# https://github.com/numpy/numpy/issues/28255 for more
869+
# details.
870+
x = np.ma.array(np.ones((x.shape), dtype=x.dtype), mask=x.mask)
871+
N = chunk.sum(x, **kwargs)
863872
else:
864873
if dtype:
865874
kwargs["dtype"] = dtype

cf/mixin/propertiesdata.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ class PropertiesData(Properties):
4949

5050
_special_properties = ("units", "calendar")
5151

52-
# def __array__(self, *dtype):
53-
# """Returns a numpy array representation of the data."""
54-
# data = self.get_data(None)
55-
# if data is not None:
56-
# return data.__array__(*dtype)#
57-
#
58-
# raise ValueError(f"{self.__class__.__name__} has no data")
52+
# def __array__(self, *dtype):
53+
# """Returns a numpy array representation of the data."""
54+
# data = self.get_data(None)
55+
# if data is not None:
56+
# return data.__array__(*dtype)#
57+
#
58+
# raise ValueError(f"{self.__class__.__name__} has no data")
5959

6060
def __contains__(self, value):
6161
"""Called to implement membership test operators.

0 commit comments

Comments
 (0)