Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Riedel <[email protected]>
  • Loading branch information
chahank and peanutfun authored Jan 3, 2024
1 parent 8f25d1f commit 0f54053
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions climada/hazard/centroids/centr.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ class Centroids():
def __init__(
self,
*,
lat: Union[np.ndarray, list],
lon: Union[np.ndarray, list],
lat: Union[np.ndarray, list[float]],
lon: Union[np.ndarray, list[float]],
crs: str = DEF_CRS,
region_id: Union[str('country'), None, np.ndarray, list] = None,
on_land: Union[str('natural_earth'), None, np.ndarray, list] = None,
region_id: Union[Literal["country"], None, np.ndarray, list[float]] = None,

Check warning on line 74 in climada/hazard/centroids/centr.py

View check run for this annotation

Jenkins - WCR / Pylint

undefined-variable

HIGH: Undefined variable 'Literal'
Raw output
Used when an undefined variable is accessed.
on_land: Union[Literal["natural_earth"], None, np.ndarray, list[float]] = None,

Check warning on line 75 in climada/hazard/centroids/centr.py

View check run for this annotation

Jenkins - WCR / Pylint

undefined-variable

HIGH: Undefined variable 'Literal'
Raw output
Used when an undefined variable is accessed.
):
"""Initialization
Expand All @@ -90,12 +90,13 @@ def __init__(
on land (True) and on sea (False) of size size. Defaults to None array
"""

attr_dict = {
'geometry': gpd.points_from_xy(lon, lat, crs=crs),
'region_id': region_id,
'on_land': on_land
}
self.gdf = gpd.GeoDataFrame(data=attr_dict)
self.gdf = gpd.GeoDataFrame(
data={
'geometry': gpd.points_from_xy(lon, lat, crs=crs),
'region_id': region_id,
'on_land': on_land,
}
)

if isinstance(region_id, str):
LOGGER.info(f'Setting region id to {region_id} level.')

Check warning on line 102 in climada/hazard/centroids/centr.py

View check run for this annotation

Jenkins - WCR / Pylint

logging-fstring-interpolation

NORMAL: Use lazy % formatting in logging functions
Raw output
no description found
Expand Down Expand Up @@ -140,7 +141,7 @@ def crs(self):

@property
def size(self):
"""Get size (number of lat/lon paris)"""
"""Get size (number of lat/lon pairs)"""
return self.gdf.shape[0]

@property
Expand Down

0 comments on commit 0f54053

Please sign in to comment.