Skip to content

Commit

Permalink
maint: fix pylint warnings
Browse files Browse the repository at this point in the history
Mostly  `dict(..) -> {..}`
  • Loading branch information
Kirill888 committed Aug 25, 2023
1 parent f5b587f commit c3f38f2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
46 changes: 23 additions & 23 deletions odc/geo/_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ def _default_cog_opts(
*, blocksize: int = 512, shape: SomeShape = (0, 0), is_float: bool = False, **other
) -> Dict[str, Any]:
nx, ny = shape_(shape).xy
return dict(
tiled=True,
blockxsize=_adjust_blocksize(blocksize, nx),
blockysize=_adjust_blocksize(blocksize, ny),
zlevel=6,
predictor=3 if is_float else 2,
compress="DEFLATE",
return {
"tiled": True,
"blockxsize": _adjust_blocksize(blocksize, nx),
"blockysize": _adjust_blocksize(blocksize, ny),
"zlevel": 6,
"predictor": 3 if is_float else 2,
"compress": "DEFLATE",
**other,
)
}


def _norm_compression_opts(
Expand Down Expand Up @@ -145,17 +145,17 @@ def _write_cog(
if (blocksize % 16) != 0:
warnings.warn("Block size must be a multiple of 16, will be adjusted")

rio_opts = dict(
width=w,
height=h,
count=nbands,
dtype=pix.dtype.name,
crs=str(geobox.crs),
transform=geobox.transform,
rio_opts = {
"width": w,
"height": h,
"count": nbands,
"dtype": pix.dtype.name,
"crs": str(geobox.crs),
"transform": geobox.transform,
**_default_cog_opts(
blocksize=blocksize, shape=wh_(w, h), is_float=pix.dtype.kind == "f"
),
)
}
if nodata is not None:
rio_opts.update(nodata=nodata)

Expand Down Expand Up @@ -376,7 +376,7 @@ def _memfiles_ovr(nlevels) -> Generator[Tuple[rasterio.MemoryFile, ...], None, N
for mem in mems[::-1]:
if not mem.closed:
mem.close()
del mem
del mems


def write_cog_layers(
Expand Down Expand Up @@ -418,13 +418,13 @@ def write_cog_layers(
)
rio_opts.update(extra_rio_opts)

first_pass_cfg: Dict[str, Any] = dict(
num_threads="ALL_CPUS",
blocksize=blocksize,
nodata=rio_opts.get("nodata", None),
use_windowed_writes=use_windowed_writes,
first_pass_cfg: Dict[str, Any] = {
"num_threads": "ALL_CPUS",
"blocksize": blocksize,
"nodata": rio_opts.get("nodata", None),
"use_windowed_writes": use_windowed_writes,
**_norm_compression_opts(intermediate_compression),
)
}

with _memfiles_ovr(len(xx)) as mm:
temp_fname = mm[0].name
Expand Down
2 changes: 1 addition & 1 deletion odc/geo/_rgba.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def colorize(
nc, cmap_dtype = 4, "uint8"

if attrs is None:
attrs = dict(**x.attrs)
attrs = {**x.attrs}
attrs.pop("nodata", None)

dims = (*x.dims, "band")
Expand Down
4 changes: 2 additions & 2 deletions odc/geo/_xr_interop.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def _coord_to_xr(name: str, c: Coordinate, **attrs) -> xarray.DataArray:
This can then be used to define coordinates for ``xr.Dataset|xr.DataArray``
"""
attrs = dict(units=c.units, resolution=c.resolution, **attrs)
attrs = {"units": c.units, "resolution": c.resolution, **attrs}
return xarray.DataArray(
c.values, coords={name: c.values}, dims=(name,), attrs=attrs
)
Expand Down Expand Up @@ -826,7 +826,7 @@ def wrap_xr(
)

if nodata is not None:
attrs = dict(nodata=nodata, **attrs)
attrs = {"nodata": nodata, **attrs}

out = xarray.DataArray(im, coords=coords, dims=dims, attrs=attrs)
if crs_coord_name is not None:
Expand Down
2 changes: 1 addition & 1 deletion odc/geo/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ def geojson(
if simplify > 0:
gg = gg.simplify(simplify)
if properties is None:
properties = dict(**props)
properties = {**props}
return {"type": "Feature", "geometry": gg.json, "properties": properties}

def split(self, splitter: "Geometry") -> Iterable["Geometry"]:
Expand Down

0 comments on commit c3f38f2

Please sign in to comment.