Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Sep 16, 2024
1 parent 6ad5092 commit 77576e7
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions pyresample/test/test_gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,14 @@ def test_resample_swath_to_area_2d(self, input_dtype):
data = xr.DataArray(da.ones(self.src_swath.shape, dtype=input_dtype),
dims=['y', 'x'])
with np.errstate(invalid="ignore"): # 'inf' space pixels cause runtime warnings
res = self.swath_resampler.compute(
data, method='bil').compute(scheduler='single-threaded')
assert res.dtype == data.dtype
assert res.values.dtype == data.dtype
assert res.shape == self.dst_area.shape
assert not np.all(np.isnan(res))
res_dask = self.swath_resampler.compute(data, method='bil')
res_np = res_dask.compute(scheduler='single-threaded')

assert res_dask.dtype == data.dtype
assert res_np.dtype == data.dtype
assert res_dask.shape == self.dst_area.shape
assert res_np.shape == self.dst_area.shape
assert not np.all(np.isnan(res_np))

@pytest.mark.parametrize("input_dtype", (np.float32, np.float64))
def test_resample_swath_to_area_3d(self, input_dtype):
Expand All @@ -270,13 +272,15 @@ def test_resample_swath_to_area_3d(self, input_dtype):
np.array([1, 2, 3])[:, np.newaxis, np.newaxis],
dims=['bands', 'y', 'x'])
with np.errstate(invalid="ignore"): # 'inf' space pixels cause runtime warnings
res = self.swath_resampler.compute(
data, method='bil').compute(scheduler='single-threaded')
assert res.dtype == data.dtype
assert res.values.dtype == data.dtype
assert res.shape == (3, ) + self.dst_area.shape
for i in range(res.shape[0]):
arr = np.ravel(res[i, :, :])
res_dask = self.swath_resampler.compute(data, method='bil')
res_np = res_dask.compute(scheduler='single-threaded')

assert res_dask.dtype == data.dtype
assert res_np.dtype == data.dtype
assert res_dask.shape == (3, ) + self.dst_area.shape
assert res_np.shape == (3, ) + self.dst_area.shape
for i in range(res_np.shape[0]):
arr = np.ravel(res_np[i, :, :])
assert np.allclose(arr[np.isfinite(arr)], float(i + 1))


Expand Down

0 comments on commit 77576e7

Please sign in to comment.