Skip to content

Commit

Permalink
Centroids.from_excel fix: switch key,val in test_storm_europe rather …
Browse files Browse the repository at this point in the history
…than in centr!
  • Loading branch information
emanuel-schmid committed Dec 8, 2023
1 parent 4079f3f commit dd7e4cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions climada/hazard/centroids/centr.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
'sheet_name': 'centroids',
'col_name': {
'region_id': 'region_id',
'latitude': 'latitude',
'longitude': 'longitude',
'lat': 'latitude',
'lon': 'longitude',
'on_land': 'on_land',
'dist_coast': 'dist_coast',
'elevation': 'elevation',
Expand Down Expand Up @@ -719,7 +719,7 @@ def from_excel(cls, file_path, crs=DEF_CRS, var_names=None):
assert 'col_name' in var_names, 'col_name must be a key in the var_names dict'

data = pd.read_excel(file_path, var_names['sheet_name']).rename(
columns={val: key for key, val in var_names['col_name'].items()}
columns=var_names['col_name']
)
return cls(**dict(data.items()), crs=crs)

Expand Down
2 changes: 1 addition & 1 deletion climada/hazard/test/test_storm_europe.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_read_with_cent(self):
"""Test from_footprints while passing in a Centroids object"""
var_names = copy.deepcopy(DEF_VAR_EXCEL)
var_names['sheet_name'] = 'fp_centroids-test'
var_names['col_name']['region_id'] = 'iso_n3'
var_names['col_name']['iso_n3'] = 'region_id'
test_centroids = Centroids.from_excel(
DATA_DIR.joinpath('fp_centroids-test.xls'),
var_names=var_names
Expand Down

0 comments on commit dd7e4cd

Please sign in to comment.