From 5233a7a2eb935c6e97d5224b8a85739aa0adc4c4 Mon Sep 17 00:00:00 2001 From: Amit Aronovitch Date: Sat, 4 Jan 2025 13:53:55 +0200 Subject: [PATCH] fix mypy errors --- telluric/georaster.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/telluric/georaster.py b/telluric/georaster.py index c2fcb8c..ba448bb 100644 --- a/telluric/georaster.py +++ b/telluric/georaster.py @@ -1187,7 +1187,7 @@ def type_min(dtype): conversion_gain = (omax - omin) / (imax - imin) # temp conversion, to handle saturation - dst_array = conversion_gain * (self.image.astype(np.float_) - imin) + omin + dst_array = conversion_gain * (self.image.astype(np.float64) - imin) + omin dst_array = np.clip(dst_array, omin, omax) else: dst_array = self.image @@ -1426,8 +1426,8 @@ def _resize(self, ratio_x, ratio_y, resampling): def to_pillow_image(self, return_mask=False): """Return Pillow. Image, and optionally also mask.""" - img = np.rollaxis(np.rollaxis(self.image.data, 2), 2) - img = Image.fromarray(img[:, :, 0]) if img.shape[2] == 1 else Image.fromarray(img) + img_data = np.rollaxis(np.rollaxis(self.image.data, 2), 2) + img = Image.fromarray(img_data[:, :, 0]) if img_data.shape[2] == 1 else Image.fromarray(img_data) if return_mask: mask = np.ma.getmaskarray(self.image) mask = Image.fromarray(np.rollaxis(np.rollaxis(mask, 2), 2).astype(np.uint8)[:, :, 0]) @@ -2371,10 +2371,14 @@ def __init__(self, rasters): super().__init__(affine=self._vrt.affine, crs=self._vrt.crs, filename=self._vrt._filename, band_names=self._vrt.band_names,) - def copy(self): + def copy(self, mutable=False): + if mutable: + raise NotImplementedError return GeoMultiRaster(self._rasters) - def to_assets(self, **attr): + def to_assets(self, name="0", **attr): + if name != "0": + raise NotImplementedError("custom asset names not supported for GeoMultiRaster") return {str(i): dict(href=raster._filename, bands=raster.band_names, __object=raster, type=RASTER_TYPE, **attr) for i, raster in enumerate(self._rasters) }