Adapt Hazard from_hdf5 and write_hdf5 to forecast attributes#1181
Merged
ValentinGebhart merged 3 commits intoforecast-classfrom Dec 9, 2025
Merged
Adapt Hazard from_hdf5 and write_hdf5 to forecast attributes#1181ValentinGebhart merged 3 commits intoforecast-classfrom
ValentinGebhart merged 3 commits intoforecast-classfrom
Conversation
chahank
reviewed
Dec 9, 2025
climada/hazard/test/test_forecast.py
Outdated
Comment on lines
121
to
123
| for key in haz_fc.__dict__.keys(): | ||
| if key not in ["intensity", "fraction"]: | ||
| npt.assert_array_equal(haz_fc.__dict__[key], haz_fc_read.__dict__[key]) |
Member
There was a problem hiding this comment.
A bit confused. What about non array values? I would expect this to fail for units, haz_type, pool, etc.
Member
There was a problem hiding this comment.
I would thus also invert the if.
if key in [intensity, fraction]:
...
elif key in [...]. (arrays)
....
else. (non arrays)
....
Collaborator
Author
There was a problem hiding this comment.
np.testing.assert_array_equal also works with the other types of our hazards, right? e.g. these all pass:
np.testing.assert_array_equal(2.,2.)
np.testing.assert_array_equal([1,2], [1,2])
I will adapt the order of the if statement
chahank
reviewed
Dec 9, 2025
climada/hazard/test/test_forecast.py
Outdated
| haz_fc_read = HazardForecast.from_hdf5(file_name) | ||
|
|
||
| assert haz_fc_read.lead_time.dtype == np.dtype("timedelta64[ns]") | ||
| assert haz_fc_read.member.dtype == int |
Member
There was a problem hiding this comment.
This test might lead to failure. The init of hazard forecast does not require integer. Just a numpy array of things.
chahank
approved these changes
Dec 9, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this PR:
This PR fixes #1134
PR Author Checklist
develop)PR Reviewer Checklist