Skip to content

Commit 0f54053

Browse files
chahankpeanutfun
andauthored
Apply suggestions from code review
Co-authored-by: Lukas Riedel <[email protected]>
1 parent 8f25d1f commit 0f54053

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

climada/hazard/centroids/centr.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ class Centroids():
6868
def __init__(
6969
self,
7070
*,
71-
lat: Union[np.ndarray, list],
72-
lon: Union[np.ndarray, list],
71+
lat: Union[np.ndarray, list[float]],
72+
lon: Union[np.ndarray, list[float]],
7373
crs: str = DEF_CRS,
74-
region_id: Union[str('country'), None, np.ndarray, list] = None,
75-
on_land: Union[str('natural_earth'), None, np.ndarray, list] = None,
74+
region_id: Union[Literal["country"], None, np.ndarray, list[float]] = None,
75+
on_land: Union[Literal["natural_earth"], None, np.ndarray, list[float]] = None,
7676
):
7777
"""Initialization
7878
@@ -90,12 +90,13 @@ def __init__(
9090
on land (True) and on sea (False) of size size. Defaults to None array
9191
"""
9292

93-
attr_dict = {
94-
'geometry': gpd.points_from_xy(lon, lat, crs=crs),
95-
'region_id': region_id,
96-
'on_land': on_land
97-
}
98-
self.gdf = gpd.GeoDataFrame(data=attr_dict)
93+
self.gdf = gpd.GeoDataFrame(
94+
data={
95+
'geometry': gpd.points_from_xy(lon, lat, crs=crs),
96+
'region_id': region_id,
97+
'on_land': on_land,
98+
}
99+
)
99100

100101
if isinstance(region_id, str):
101102
LOGGER.info(f'Setting region id to {region_id} level.')
@@ -140,7 +141,7 @@ def crs(self):
140141

141142
@property
142143
def size(self):
143-
"""Get size (number of lat/lon paris)"""
144+
"""Get size (number of lat/lon pairs)"""
144145
return self.gdf.shape[0]
145146

146147
@property

0 commit comments

Comments
 (0)