Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
db74ab3
Fix interp performance regression for vectorized interpolation
headtr1ck Oct 6, 2026
ef9d63d
Add PR number to whats-new
headtr1ck Oct 6, 2026
43c38ff
Use the use_dask fixture in test_interp_vectorized_empty_dim
headtr1ck Oct 6, 2026
722c0cd
Merge branch 'main' into interp-perf
headtr1ck Oct 6, 2026
c220924
Fix interp with scalar new coordinates on numpy<2
headtr1ck Oct 6, 2026
07e747a
Merge remote-tracking branch 'upstream/main' into interp-perf
headtr1ck Oct 7, 2026
c79b40f
Add vectorize="shared" to apply_ufunc and use it in interp
headtr1ck Oct 7, 2026
b743bf1
Add apply_ufunc examples from basic to advanced
headtr1ck Oct 7, 2026
28ee4a1
Add vectorize="shared" to the apply_ufunc example notebook
headtr1ck Oct 7, 2026
13ff770
Use the numpy docstring style for _vectorize_shared
headtr1ck Oct 8, 2026
597bdd7
Document the numpy docstring style in CLAUDE.md
headtr1ck Oct 8, 2026
de8bafe
Merge remote-tracking branch 'upstream/main' into interp-perf
headtr1ck Oct 8, 2026
3b4fa28
Type the function vectorized by _vectorize_shared
headtr1ck Oct 8, 2026
e2a25af
Merge remote-tracking branch 'upstream/main' into interp-perf
headtr1ck Oct 8, 2026
9cd6bd0
Merge branch 'main' into interp-perf
headtr1ck Oct 20, 2026
da39dca
Replace vectorize="shared" with explicit loop dimensions, drop exampl…
headtr1ck Oct 20, 2026
2a27f9b
Restore whats-new entry of a previous release
headtr1ck Oct 20, 2026
effa06c
Shorten apply_ufunc docstring, unlink removed notebook in whats-new
headtr1ck Oct 20, 2026
cd602af
Keep vectorize_dims ordered and pass it directly
headtr1ck Oct 20, 2026
7f84169
Clarify comment on vectorize
headtr1ck Oct 20, 2026
27ce6b4
Test vectorize=[]
headtr1ck Oct 20, 2026
fff68f5
Use an interpolation example for vectorize=[dims]
headtr1ck Oct 20, 2026
dda83a0
Localize each block for chunked destination coordinates
headtr1ck Oct 22, 2026
3aa1d7a
Merge remote-tracking branch 'upstream/main' into interp-perf
headtr1ck Oct 22, 2026
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
59 changes: 59 additions & 0 deletions asv_bench/benchmarks/interp.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from typing import Any

import numpy as np
import pandas as pd
from asv_runner.benchmarks.mark import parameterize

import xarray as xr
from xarray.core.types import InterpOptions

from . import randn, requires_dask

Expand Down Expand Up @@ -64,3 +67,59 @@ def setup(self, *args, **kwargs):
requires_dask()
super().setup(**kwargs)
self.ds = self.ds.chunk({"t": 50})


class InterpolationVectorized:
# the destination coordinates vary along a dimension of the source (GH10683)
def setup(self, *args, **kwargs):
nt, nr, nz = 100, 50, 50
self.da = xr.DataArray(
randn((nt, nr, nz)),
dims=("t", "r", "z"),
coords={
"t": np.arange(nt),
"r": np.arange(nr),
"z": np.linspace(0, 1, nz),
},
)
self.new_z = xr.DataArray(np.linspace(0.1, 0.9, nt), dims="t")

@parameterize({"method": ["linear", "cubic"]})
def time_interpolation_vectorized(self, method):
self.da.interp(z=self.new_z, method=method).compute()


class InterpolationVectorizedDask(InterpolationVectorized):
def setup(self, *args, **kwargs):
requires_dask()
super().setup(**kwargs)
self.da = self.da.chunk({"t": 25, "r": 25})


class InterpolationDaskChunkedCoords:
# scipy casts integer data to float, which copies the whole block unless
# it is localized to the range of the (chunked) destination coordinates
def setup(self, *args: Any, **kwargs: Any) -> None:
requires_dask()
import dask.array

ny, nx = 16, 2_000_000
chunks = (8, nx) # 122 MiB blocks, generated lazily
self.data = {
"int": dask.array.random.randint(0, 100, (ny, nx), chunks=chunks),
"float": dask.array.random.random((ny, nx), chunks=chunks),
}
self.x = np.arange(nx)
self.new_x = xr.DataArray(
dask.array.linspace(1000, 1500, 400, chunks=100), dims="z"
)

@parameterize({"method": ["linear", "nearest"], "dtype": ["int", "float"]})
def peakmem_interpolation_chunked_coords(
self, method: InterpOptions, dtype: str
) -> None:
import dask

da = xr.DataArray(self.data[dtype], dims=("y", "x"), coords={"x": self.x})
with dask.config.set(scheduler="synchronous"):
da.interp(x=self.new_x, method=method).compute()
1 change: 0 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
copybutton_prompt_is_regexp = True

# myst-nb
nb_execution_excludepatterns = ["examples/apply_ufunc_vectorize_1d.ipynb"]
# RTD does not publish the .err.log report, so print tracebacks in the build log
nb_execution_show_tb = True

Expand Down
Loading
Loading