Create an empty centroids in Hazard.concat() with CRS from the first haz_list. by manniepmkam · Pull Request #881 · CLIMADA-project/climada_python
Conversation
Comment on lines +819 to +821
| haz_concat = haz_list[0].__class__() | ||
| haz_concat.haz_type = haz_list[0].haz_type | ||
| haz_concat.centroids = Centroids(lat=[], lon=[], crs=haz_list[0].centroids.crs) |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly! 😄
Alternatively one may inject the centroids as an argument of haz_list[0].__class__. (And possibly skip the haz_type assignment. I suspect that it is already assigned at that point through the constructor)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manniepmkam, as discussed in person, please
- fix the linter issue: Line too long
- add a unit test that covers the case reported in #879 (comment)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but you should check for the exact error message and not just any ValueError, see my comment.
gdeskos pushed a commit to gdeskos/climada_python that referenced this pull request
Sep 16, 2024…rd (CLIMADA-project#881) * add test for Hazard.concat for failing crs * Update error message for Centroids.append
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters