Skip to content

Commit

Permalink
Add missing meta keyword arguments on all dask map_blocks calls
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Nov 17, 2023
1 parent 6a8afc0 commit d9b76f5
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyresample/_spatial_mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def _run_jobs(target, args, nprocs):
p.join()
if ierr.value != 0:
raise RuntimeError('%d errors in worker processes. Last one reported:\n%s' %
(ierr.value, warn_msg.value.decode()))
(ierr.value, warn_msg.value._object_hook()))

# This is executed in an external process:

Expand Down
7 changes: 6 additions & 1 deletion pyresample/bilinear/xarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,12 @@ def _check_data_shape(data, input_xy_shape):

# Ensure two dimensions
if data.ndim == 1:
data = DataArray(da.map_blocks(np.expand_dims, data.data, 0, new_axis=[0]))
data = DataArray(da.map_blocks(np.expand_dims,
data.data,
0,
meta=np.array((), dtype=data.dtype),
dtype=data.dtype,
new_axis=[0]))

return data

Expand Down
2 changes: 2 additions & 0 deletions pyresample/bucket/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ def _get_indices(self):
lons = self.source_lons.ravel()
lats = self.source_lats.ravel()
result = da.map_blocks(self._get_proj_coordinates, lons, lats,
meta=np.array((), dtype=lons.dtype),
dtype=lons.dtype,
new_axis=0, chunks=(2,) + lons.chunks)
proj_x = result[0, :]
proj_y = result[1, :]
Expand Down
2 changes: 2 additions & 0 deletions pyresample/future/resamplers/nearest.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def _query_resample_kdtree(self,
valid_output_index, 'ji', *args, kdtree=resample_kdtree,
neighbours=neighbors, epsilon=epsilon,
radius=radius_of_influence, dtype=np.int64,
meta=np.array((), dtype=np.int64),
new_axes={'k': neighbors}, concatenate=True)
return res

Expand Down Expand Up @@ -338,6 +339,7 @@ def get_sample_from_neighbor_info(
new_data, src_adims,
vii_slices=vii_slices, ia_slices=ia_slices,
fill_value=fill_value,
met=np.array((), dtype=new_data.dtype),
dtype=new_data.dtype, concatenate=True)
res = DataArray(res, dims=dst_dims,
attrs=deepcopy(data.attrs))
Expand Down
4 changes: 4 additions & 0 deletions pyresample/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,12 +837,16 @@ def aggregate(self, **dims):
res = da.map_blocks(self._do_transform, latlong, geocent,
self.lons.data, self.lats.data,
da.zeros_like(self.lons.data), new_axis=[2],
meta=np.array((), dtype=self.lons.dtype),
dtype=self.lons.dtype,
chunks=(self.lons.chunks[0], self.lons.chunks[1], 3))
res = DataArray(res, dims=['y', 'x', 'coord'], coords=self.lons.coords)
res = res.coarsen(**dims).mean()
lonlatalt = da.map_blocks(self._do_transform, geocent, latlong,
res[:, :, 0].data, res[:, :, 1].data,
res[:, :, 2].data, new_axis=[2],
meta=np.array((), dtype=res.dtype),
dtype=res.dtype,
chunks=res.data.chunks)
lons = DataArray(lonlatalt[:, :, 0], dims=self.lons.dims,
coords=res.coords, attrs=self.lons.attrs.copy())
Expand Down
2 changes: 2 additions & 0 deletions pyresample/kd_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ def query_resample_kdtree(self,
valid_oi, 'ji', *args, kdtree=resample_kdtree,
neighbours=self.neighbours, epsilon=self.epsilon,
radius=self.radius_of_influence, dtype=np.int64,
meta=np.array((), dtype=np.int64),
new_axes={'k': self.neighbours}, concatenate=True)
return res, None

Expand Down Expand Up @@ -1134,6 +1135,7 @@ def contain_coords(var, coord_list):
new_data, src_adims,
vii_slices=vii_slices, ia_slices=ia_slices,
fill_value=fill_value,
meta=np.array((), dtype=new_data.dtype),
dtype=new_data.dtype, concatenate=True)
res = DataArray(res, dims=dst_dims, coords=coords,
attrs=deepcopy(data.attrs))
Expand Down
1 change: 1 addition & 0 deletions pyresample/utils/proj4.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def transform(self, x, y, **kwargs):
result = da.map_blocks(_transform_dask_chunk, x, y,
crs_from.to_wkt(), crs_to.to_wkt(),
dtype=x.dtype, chunks=x.chunks + ((2,),),
meta=np.array((), dtype=x.dtype),
kwargs=self.kwargs,
transform_kwargs=kwargs,
new_axis=x.ndim)
Expand Down

0 comments on commit d9b76f5

Please sign in to comment.