Skip to content

Commit e6e9663

Browse files
committed
Added whatsnew for co_realise_cubes.
1 parent 499972c commit e6e9663

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Added new function :func:`iris.co_realise_cubes` to compute multiple results
2+
in parallel, avoiding repeated data fetches or computations.
3+

lib/iris/_lazy_data.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,13 @@ def as_lazy_data(data, chunks=None, asarray=False):
104104

105105
def _co_realise_lazy_arrays(arrays):
106106
"""
107-
Compute multiple lazy arrays together + return a list of real values.
107+
Compute multiple lazy arrays and return a list of real values.
108108
109-
Also converts any MaskedConstants to arrays, to ensure that the dtypes of
110-
the results are the same as the inputs.
111-
This part is only necessary because of problems with masked constants.
109+
All the arrays are computed together, so they can share results from common
110+
graph elements.
111+
112+
Also converts any MaskedConstants returned into masked arrays, to ensure
113+
that all return values are writeable NumPy array objects.
112114
113115
"""
114116
results = list(da.compute(*arrays))
@@ -120,7 +122,7 @@ def _co_realise_lazy_arrays(arrays):
120122
# Recorded in https://github.com/dask/dask/issues/2111.
121123
result = ma.masked_array(result.data, mask=result.mask,
122124
dtype=array.dtype)
123-
# Replace the original result array.
125+
# When we change one, update the result list.
124126
results[i_array] = result
125127
return results
126128

@@ -182,7 +184,7 @@ def co_realise_cubes(cubes):
182184
183185
This fetches lazy content, equivalent to accessing each cube.data.
184186
However, lazy calculations and data fetches can be shared between the
185-
calculations, improving performance.
187+
computations, improving performance.
186188
187189
"""
188190
results = _co_realise_lazy_arrays([cube.core_data() for cube in cubes])

0 commit comments

Comments
 (0)