1616
1717---
1818
19- Define interpolation and extrapolation functions for calculating (local) exceedance frequencies and return periods
19+ Define interpolation and extrapolation functions for calculating
20+ (local) exceedance frequencies and return periods
2021"""
2122
2223import logging
@@ -46,11 +47,11 @@ def preprocess_and_interpolate_ev(
4647 Parameters
4748 ----------
4849 test_frequency : array_like
49- 1-D array of test frequencies for which values (e.g., intensities or impacts) should be assigned.
50- If given, test_values must be None.
50+ 1-D array of test frequencies for which values (e.g., intensities or impacts) should be
51+ assigned. If given, test_values must be None.
5152 test_values : array_like
52- 1-D array of test values (e.g., intensities or impacts) for which frequencies should be assigned.
53- If given, test_frequency must be None.
53+ 1-D array of test values (e.g., intensities or impacts) for which frequencies should be
54+ assigned. If given, test_frequency must be None.
5455 frequency : array_like
5556 1-D array of frequencies to be interpolated.
5657 values : array_like
@@ -104,7 +105,7 @@ def preprocess_and_interpolate_ev(
104105 "Both test frequencies and test values are given. This method only handles one of "
105106 "the two. To use this method, please only use one of them."
106107 )
107- elif test_frequency is None and test_values is None :
108+ if test_frequency is None and test_values is None :
108109 raise ValueError ("No test values or test frequencies are given." )
109110
110111 # sort values and frequencies
@@ -128,18 +129,17 @@ def preprocess_and_interpolate_ev(
128129 y_threshold = value_threshold ,
129130 y_asymptotic = y_asymptotic ,
130131 )
131- else :
132- extrapolation = None if method == "interpolate" else method
133- return _interpolate_ev (
134- test_frequency ,
135- frequency [::- 1 ],
136- values [::- 1 ],
137- logx = log_frequency ,
138- logy = log_values ,
139- y_threshold = value_threshold ,
140- extrapolation = extrapolation ,
141- y_asymptotic = y_asymptotic ,
142- )
132+ extrapolation = None if method == "interpolate" else method
133+ return _interpolate_ev (
134+ test_frequency ,
135+ frequency [::- 1 ],
136+ values [::- 1 ],
137+ logx = log_frequency ,
138+ logy = log_values ,
139+ y_threshold = value_threshold ,
140+ extrapolation = extrapolation ,
141+ y_asymptotic = y_asymptotic ,
142+ )
143143
144144 # if test values are provided
145145 else :
@@ -151,17 +151,16 @@ def preprocess_and_interpolate_ev(
151151 x_threshold = value_threshold ,
152152 y_asymptotic = y_asymptotic ,
153153 )
154- else :
155- extrapolation = None if method == "interpolate" else method
156- return _interpolate_ev (
157- test_values ,
158- values ,
159- frequency ,
160- logx = log_values ,
161- logy = log_frequency ,
162- x_threshold = value_threshold ,
163- extrapolation = extrapolation ,
164- )
154+ extrapolation = None if method == "interpolate" else method
155+ return _interpolate_ev (
156+ test_values ,
157+ values ,
158+ frequency ,
159+ logx = log_values ,
160+ logy = log_frequency ,
161+ x_threshold = value_threshold ,
162+ extrapolation = extrapolation ,
163+ )
165164
166165
167166def _interpolate_ev (
@@ -377,7 +376,8 @@ def _group_frequency(frequency, value, n_sig_dig):
377376 if not all (sorted (start_indices ) == start_indices ):
378377 LOGGER .warning (
379378 "After grouping values to significant digits, the value array is not sorted."
380- f"The values are not binned. Please choose a larger value of n_sig_dig={ n_sig_dig } ."
379+ "The values are not binned. Please choose a larger value of n_sig_dig=%s." ,
380+ n_sig_dig ,
381381 )
382382 return frequency , value
383383
@@ -389,13 +389,13 @@ def _group_frequency(frequency, value, n_sig_dig):
389389 return frequency , value
390390
391391
392- def round_to_sig_digits (x , n_sig_dig ):
392+ def round_to_sig_digits (values , n_sig_dig ):
393393 """round each element array to a number of significant digits
394394
395395 Parameters
396396 ----------
397- x : array-like
398- array to be rounded
397+ values : array-like
398+ values to be rounded
399399 n_sig_dig : int
400400 number of significant digits.
401401
@@ -406,5 +406,5 @@ def round_to_sig_digits(x, n_sig_dig):
406406 """
407407
408408 return np .vectorize (np .format_float_positional )(
409- x , precision = n_sig_dig , unique = False , fractional = False , trim = "k"
409+ values , precision = n_sig_dig , unique = False , fractional = False , trim = "k"
410410 ).astype (float )
0 commit comments