Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use realized data in benchmarks when requested #6339

Merged
merged 3 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions benchmarks/benchmarks/generate_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,14 @@ def load_realised():
file loading, but some benchmarks are only meaningful if starting with real
arrays.
"""
from iris.fileformats._nc_load_rules import helpers
from iris.fileformats.netcdf.loader import _get_cf_var_data as pre_patched

def patched(cf_var, filename):
return as_concrete_data(pre_patched(cf_var, filename))

netcdf._get_cf_var_data = patched
yield netcdf
netcdf._get_cf_var_data = pre_patched
netcdf.loader._get_cf_var_data = patched
helpers._get_cf_var_data = patched
yield
netcdf.loader._get_cf_var_data = pre_patched
helpers._get_cf_var_data = pre_patched
3 changes: 2 additions & 1 deletion benchmarks/benchmarks/generate_data/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def realistic_4d_w_everything(w_mesh=False, lazy=False) -> iris.cube.Cube:
lazy : bool
If True, the Cube will be returned with all arrays as they would
normally be loaded from file (i.e. most will still be lazy Dask
arrays). If False, all arrays will be realised NumPy arrays.
arrays). If False, all arrays (except derived coordinates) will be
realised NumPy arrays.

"""

Expand Down
3 changes: 3 additions & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ This document explains the changes made to Iris for this release
#. `@trexfeathers`_ temporarily pinned Sphinx to `<8.2`.
(:pull:`6344`, :issue:`6345`)

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


.. comment
Whatsnew author names (@github name) in alphabetical order. Note that,
Expand Down
Loading