Skip to content

Commit 9fede7c

Browse files
authored
Use realized data in benchmarks when requested (SciTools#6339)
* Use realized data in benchmarks when requested * Add whatsnew
1 parent 409b1d1 commit 9fede7c

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

benchmarks/benchmarks/generate_data/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,14 @@ def load_realised():
106106
file loading, but some benchmarks are only meaningful if starting with real
107107
arrays.
108108
"""
109+
from iris.fileformats._nc_load_rules import helpers
109110
from iris.fileformats.netcdf.loader import _get_cf_var_data as pre_patched
110111

111112
def patched(cf_var, filename):
112113
return as_concrete_data(pre_patched(cf_var, filename))
113114

114-
netcdf._get_cf_var_data = patched
115-
yield netcdf
116-
netcdf._get_cf_var_data = pre_patched
115+
netcdf.loader._get_cf_var_data = patched
116+
helpers._get_cf_var_data = patched
117+
yield
118+
netcdf.loader._get_cf_var_data = pre_patched
119+
helpers._get_cf_var_data = pre_patched

benchmarks/benchmarks/generate_data/stock.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ def realistic_4d_w_everything(w_mesh=False, lazy=False) -> iris.cube.Cube:
162162
lazy : bool
163163
If True, the Cube will be returned with all arrays as they would
164164
normally be loaded from file (i.e. most will still be lazy Dask
165-
arrays). If False, all arrays will be realised NumPy arrays.
165+
arrays). If False, all arrays (except derived coordinates) will be
166+
realised NumPy arrays.
166167
167168
"""
168169

docs/src/whatsnew/latest.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ This document explains the changes made to Iris for this release
145145
#. `@trexfeathers`_ temporarily pinned Sphinx to `<8.2`.
146146
(:pull:`6344`, :issue:`6345`)
147147

148+
#. `@bouweandela`_ fixed a bug in the benchmarking code that caused all benchmarks
149+
to be run with lazy data. (:pull:`6339`)
150+
148151

149152
.. comment
150153
Whatsnew author names (@github name) in alphabetical order. Note that,

0 commit comments

Comments
 (0)