Skip to content

resample: cubic on dask backends fails for arrays smaller than depth=16 #2547

@brendancol

Description

@brendancol

Summary

resample(method='cubic') on dask+numpy or dask+cupy raises
ValueError: The overlapping depth 16 is larger than your array <N>
when the input array is smaller than 16 cells along either axis.

The cubic prefilter depth was raised to 16 in #1464 to drive the IIR
boundary transient below float32 epsilon. _ensure_min_chunksize
enforces min_size = max(2 * depth + 1, ...), so it grows individual
chunks to 33+ cells -- but dask's overlap() still rejects when the
array total is below depth, which happens for an Nx1 column or a
single tiny chunk.

Reproducer

import numpy as np
import dask.array as da
from xrspatial.resample import resample
from xrspatial.tests.general_checks import create_test_raster

data = np.array([[i + 1.0] for i in range(8)], dtype=np.float32)
agg = create_test_raster(data, backend='dask+numpy', dims=['y', 'x'],
                         attrs={'res': (1.0, 1.0)}, chunks=(2, 1))
resample(agg, scale_factor=0.5, method='cubic')
# ValueError: The overlapping depth 16 is larger than your array 8.

The eager numpy and cupy paths handle this case fine; only the
dask backends fail.

Expected

Either:

  1. The cubic dask path falls back to a depth small enough for the
    array size when the array is too small to absorb depth=16.
  2. The dask path materialises the small array (sum of chunks[ax] <
    depth) and runs the eager kernel before re-chunking the result.
  3. The error message is rewritten to point at the documented
    minimum-size constraint so users can size their inputs.

Coverage gate

A test in test_resample_coverage_2026_05_27.py::TestSingleColumnRaster::test_nx1_downsample
currently skips this combination. Remove the pytest.skip block once
the fix lands.

Discovered via

/deep-sweep test-coverage on the resample module, 2026-05-27.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions