Skip to content

Commit c75c93a

Browse files
authored
Add missing type annotations (#546)
add type annotations to snow_mask add type annotations to geometry_io
1 parent dfada66 commit c75c93a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

io/eolearn/io/geometry_io.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(
4646
self.clip = clip
4747

4848
@abc.abstractmethod
49-
def _load_vector_data(self, bbox: Optional[BBox]):
49+
def _load_vector_data(self, bbox: Optional[BBox]) -> gpd.GeoDataFrame:
5050
"""Loads vector data given a bounding box"""
5151

5252
def _reproject_and_clip(self, vectors: gpd.GeoDataFrame, bbox: Optional[BBox]) -> gpd.GeoDataFrame:
@@ -122,7 +122,7 @@ def __init__(
122122

123123
self.fiona_kwargs = kwargs
124124
self._aws_session = None
125-
self._dataset_crs = None
125+
self._dataset_crs: Optional[CRS] = None
126126

127127
super().__init__(feature=feature, reproject=reproject, clip=clip, config=config)
128128

@@ -163,7 +163,7 @@ def dataset_crs(self) -> Optional[CRS]:
163163

164164
return self._dataset_crs
165165

166-
def _read_crs(self):
166+
def _read_crs(self) -> None:
167167
"""Reads information about CRS from a dataset"""
168168
with fiona.open(self.full_path, **self.fiona_kwargs) as features:
169169
self._dataset_crs = CRS(features.crs)

mask/eolearn/mask/snow_mask.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
self.undefined_value = undefined_value
5151
self.mask_feature = (FeatureType.MASK, mask_name)
5252

53-
def _apply_dilation(self, snow_masks):
53+
def _apply_dilation(self, snow_masks: np.ndarray) -> np.ndarray:
5454
"""Apply binary dilation for each mask in the series"""
5555
if self.dilation_size:
5656
snow_masks = np.array([binary_dilation(mask, disk(self.dilation_size)) for mask in snow_masks])
@@ -148,7 +148,7 @@ def __init__(
148148
red_params: Tuple[float, float, float, float, float] = (12, 0.3, 0.1, 0.2, 0.040),
149149
ndsi_params: Tuple[float, float, float] = (0.4, 0.15, 0.001),
150150
b10_index: Optional[int] = None,
151-
**kwargs,
151+
**kwargs: Any,
152152
):
153153
"""
154154
:param data_feature: EOPatch feature represented by a tuple in the form of `(FeatureType, 'feature_name')`
@@ -187,7 +187,7 @@ def __init__(
187187
self.b10_index = b10_index
188188
self._validate_params()
189189

190-
def _validate_params(self):
190+
def _validate_params(self) -> None:
191191
"""Check length of parameters defining threshold values"""
192192
for params, n_params in [(self.dem_params, 2), (self.red_params, 5), (self.ndsi_params, 3)]:
193193
if not isinstance(params, (tuple, list)) or len(params) != n_params:
@@ -229,7 +229,7 @@ def _adjust_cloud_mask(
229229
).astype(np.uint8)
230230

231231
def _apply_first_pass(
232-
self, bands: np.ndarray, ndsi: np.ndarray, clm: np.ndarray, dem, clm_temp: np.ndarray
232+
self, bands: np.ndarray, ndsi: np.ndarray, clm: np.ndarray, dem: np.ndarray, clm_temp: np.ndarray
233233
) -> Tuple[np.ndarray, Optional[np.ndarray], np.ndarray]:
234234
"""Apply first pass of snow detection"""
235235
snow_mask_pass1 = np.where(

0 commit comments

Comments
 (0)