Skip to content

Commit 8f4e0b9

Browse files
committed
Fix type for return_year in extreme.return_year_value
In an oversight in merging MHKiT-Software#193 the docstring was updated for the type of return_year in return_year_value but the corresponding assertion was not. Tests for the types of the two input parameters have been added to try to avoid a simular situation occuring the future.
1 parent f23f123 commit 8f4e0b9

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

mhkit/loads/extreme.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ def return_year_value(ppf, return_year, short_term_period_hr):
749749
The value corresponding to the return period from the distribution.
750750
"""
751751
assert callable(ppf)
752-
assert isinstance(return_year, int)
752+
assert isinstance(return_year, (float, int))
753753
assert isinstance(short_term_period_hr, (float, int))
754754

755755
p = 1 / (return_year * 365.25 * 24 / short_term_period_hr)

mhkit/tests/loads/test_loads.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,17 @@ def test_mler_export_time_series(self):
181181
assert_frame_equal(self.mler_ts, mler_ts, atol=0.0001)
182182

183183
def test_return_year_value(self):
184+
return_years = [50, 50.0]
185+
short_term_periods = [1, 1.0]
184186
dist = stats.norm
185-
return_year = 50
186-
short_term_period = 1
187187

188-
val = loads.extreme.return_year_value(dist.ppf, return_year, short_term_period)
189-
want = 4.5839339
190-
self.assertAlmostEqual(want, val, 5)
188+
for y in return_years:
189+
for stp in short_term_periods:
190+
with self.subTest(year=y, short_term=stp):
191+
val = loads.extreme.return_year_value(
192+
dist.ppf, y, stp)
193+
want = 4.5839339
194+
self.assertAlmostEqual(want, val, 5)
191195

192196
def test_longterm_extreme(self):
193197
ste_1 = stats.norm

0 commit comments

Comments
 (0)