Skip to content

Conversation

@manniepmkam
Copy link
Collaborator

@manniepmkam manniepmkam commented May 10, 2024

Changes proposed in this PR:

This pull request is a fix for issue #879.

An empty centroids is created in the Hazard.concat() function with the crs from the haz object from the haz_list.

This PR fixes #

PR Author Checklist

PR Reviewer Checklist

@emanuel-schmid
Copy link
Collaborator

Very well! Can you add tests and changelog?

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)
Copy link
Collaborator

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)

Copy link
Member

@peanutfun peanutfun left a comment

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)

@manniepmkam
Copy link
Collaborator Author

manniepmkam commented Jun 17, 2024

@manniepmkam, as discussed in person, please

  • fix the linter issue: Line too long

I have updated the line.

The unit test for hazard.base has been updated accordingly. Please review that.

Copy link
Member

@peanutfun peanutfun left a 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.

@peanutfun peanutfun merged commit 770e941 into develop Jun 18, 2024
@peanutfun
Copy link
Member

@manniepmkam Thanks a lot for the bugfix! 🙌

@emanuel-schmid emanuel-schmid deleted the feature/fix_haz_centr_crs branch June 28, 2024 10:46
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants