Skip to content

proximity: bounded dask EUCLIDEAN allocation can NaN a target at a float32-ulp max_distance #3392

@brendancol

Description

@brendancol

Describe the bug

Split off from #3389 / #3391, which fixed the CPU-vs-GPU brute-force divergence. A separate, pre-existing edge remains on the bounded dask+numpy path.

For EUCLIDEAN (or MANHATTAN) allocation/direction on a dask array with a finite max_distance, a target whose distance lands exactly in the float32 ulp gap of max_distance can come back NaN under dask, while the eager numpy backend returns the target. The divergence comes from the bounded map_overlap halo-sizing path (_halo_depth / chunk handling), not from the per-pixel comparison that #3389 fixed.

Reproducer

import numpy as np, xarray as xr
import dask.array as da
from xrspatial import allocation
from xrspatial.proximity import euclidean_distance

lon = np.array([0.0, 0.1, 0.7]); lat = np.array([0.0])
data = np.zeros((1, 3)); data[0, 0] = 9.0
j = 2
d64 = euclidean_distance(lon[0], lon[j], lat[0], lat[0])
md = (float(np.float32(d64)) + d64) / 2.0   # in the float32 ulp gap

r = xr.DataArray(data.copy(), dims=['lat','lon'], coords={'lon':lon,'lat':lat})
r.data = da.from_array(r.data, chunks=(1, 2))
print(allocation(r, x='lon', y='lat', max_distance=md).data.compute()[0, j])  # nan
# eager numpy / cupy return 9.0 (after #3389)

Expected behavior

Bounded dask EUCLIDEAN/MANHATTAN allocation/direction should agree with the eager backends at a float32-ulp max_distance.

Severity

Low. Surfaces only at sub-ulp max_distance precision, an adversarial input. Filed for tracking so it is not lost.

Found by /sweep-accuracy on the proximity module; split out of #3389.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:proximityArea: proximitybugSomething isn't workingdaskDask backend / chunked arrayssweep-accuracyFound by /sweep-accuracy

    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