Skip to content
Merged
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
21 changes: 18 additions & 3 deletions xrspatial/tests/test_reproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2435,8 +2435,23 @@ def test_merge_dask_same_crs_matches_eager(self):
np.testing.assert_array_equal(eager[~eager_nan], dasked[~dask_nan])

def test_merge_dask_different_crs_matches_eager(self):
"""Different-CRS merge should match within float tolerance."""
"""Different-CRS merge should match within float tolerance.

Uses the synchronous dask scheduler. Multi-CRS reprojection
creates a fresh ``pyproj.Transformer`` per chunk, and PROJ's
first-time CRS-database load is not safe under concurrent
threaded workers on macOS (the test would SIGABRT mid-compute).
Synchronous compute exercises the same dask graph without the
threading dimension; CRS thread-safety is its own concern,
outside the scope of this parity test.
"""
import pyproj
from xrspatial.reproject import merge
# Pre-warm the PROJ database in this thread so that any first-init
# work happens here, not concurrently inside dask compute.
pyproj.CRS.from_epsg(4326)
pyproj.CRS.from_epsg(3857)

a_data = np.arange(256, dtype=np.float64).reshape(16, 16)
b_data = (np.arange(256, dtype=np.float64) + 100.0).reshape(16, 16)
# One in WGS84, one in Web Mercator (forces reprojection)
Expand All @@ -2448,7 +2463,7 @@ def test_merge_dask_different_crs_matches_eager(self):

eager = merge(
[a, b], target_crs='EPSG:4326', resolution=1.0,
).compute().values
).compute(scheduler='synchronous').values

a_dask = a.copy()
b_dask = b.copy()
Expand All @@ -2457,7 +2472,7 @@ def test_merge_dask_different_crs_matches_eager(self):
dasked = merge(
[a_dask, b_dask], target_crs='EPSG:4326',
resolution=1.0, chunk_size=8,
).compute().values
).compute(scheduler='synchronous').values

assert eager.shape == dasked.shape
np.testing.assert_array_equal(np.isnan(eager), np.isnan(dasked))
Expand Down
Loading