Skip to content

Commit

Permalink
Fix some mypy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mdales committed Sep 29, 2024
1 parent 65e68b4 commit e2de1f5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions yirgacheffe/layers/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ def __init__(self, dataset, name: Optional[str] = None, band: int = 1):

transform = dataset.GetGeoTransform()

pixel_scale = self.pixel_scale
assert pixel_scale # from raster we should always have one

self._underlying_area = Area(
floor(-180 / self.pixel_scale.xstep) * self.pixel_scale.xstep,
floor(-180 / pixel_scale.xstep) * pixel_scale.xstep,
self.area.top,
ceil(180 / self.pixel_scale.xstep) * self.pixel_scale.xstep,
ceil(180 / pixel_scale.xstep) * pixel_scale.xstep,
self.area.bottom
)
self._active_area = self._underlying_area
Expand Down
2 changes: 1 addition & 1 deletion yirgacheffe/layers/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def layer_from_files(cls, filenames: List[str], name: Optional[str] = None) -> G
rasters = [RasterLayer.layer_from_file(x) for x in filenames]
return cls(rasters, name)

def __init__(self, layers: List[YirgacheffeLayer], name: Optional[str] = None) -> GroupLayerT:
def __init__(self, layers: List[YirgacheffeLayer], name: Optional[str] = None) -> None:
if not layers:
raise GroupLayerEmpty("Expected one or more layers")
if not are_pixel_scales_equal_enough([x.pixel_scale for x in layers]):
Expand Down
3 changes: 3 additions & 0 deletions yirgacheffe/layers/rasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,14 @@ def _unpark(self):
def datatype(self) -> int:
if self._dataset is None:
self._unpark()
assert self._dataset
return self._dataset.GetRasterBand(1).DataType

def read_array(self, xoffset, yoffset, xsize, ysize) -> Any:
if self._dataset is None:
self._unpark()
assert self._dataset

if (xsize <= 0) or (ysize <= 0):
raise ValueError("Request dimensions must be positive and non-zero")

Expand Down
7 changes: 5 additions & 2 deletions yirgacheffe/layers/rescaled.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ def __init__(
self._src = src
self._nearest_neighbour = nearest_neighbour

self._x_scale = src._pixel_scale.xstep / pixel_scale.xstep
self._y_scale = src._pixel_scale.ystep / pixel_scale.ystep
src_pixel_scale = src.pixel_scale
assert src_pixel_scale # from raster we should always have one

self._x_scale = src_pixel_scale.xstep / pixel_scale.xstep
self._y_scale = src_pixel_scale.ystep / pixel_scale.ystep

def close(self):
self._src.close()
Expand Down

0 comments on commit e2de1f5

Please sign in to comment.