Skip to content

Commit e0ba070

Browse files
adapted docstrings
1 parent b3c1f13 commit e0ba070

File tree

3 files changed

+28
-30
lines changed

3 files changed

+28
-30
lines changed

climada/engine/impact.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ def local_exceedance_impact(
556556
Notes
557557
-------
558558
Contrary to Impact.calc_freq_curve(), impacts are binned according to their n_sig_dig
559-
significant digits. This results in a coarser (and smoother) interpolation, and a
559+
significant digits. This results in a smoother (and coarser) interpolation, and a
560560
more stable extrapolation. To not bin the values, please use a large value for n_sig_dig,
561561
e.g., n_sig_dig=7. For more information about the binning, see
562562
climada.util.interpolation.preprocess_and_interpolate_ev().
@@ -709,7 +709,7 @@ def local_return_period(
709709
Notes
710710
-------
711711
Contrary to Impact.calc_freq_curve(), impacts are binned according to their n_sig_dig
712-
significant digits. This results in a coarser (and smoother) interpolation, and a
712+
significant digits. This results in a smoother (and coarser) interpolation, and a
713713
more stable extrapolation. To not bin the values, please use a large value for n_sig_dig,
714714
e.g., n_sig_dig=7. For more information about the binning, see
715715
climada.util.interpolation.preprocess_and_interpolate_ev().

climada/hazard/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ def local_exceedance_intensity(
550550
Notes
551551
-------
552552
Contrary to Impact.calc_freq_curve(), intensities are binned according to their n_sig_dig
553-
significant digits. This results in a coarser (and smoother) interpolation, and a
553+
significant digits. This results in a smoother (and coarser) interpolation, and a
554554
more stable extrapolation. To not bin the values, please use a large value for n_sig_dig,
555555
e.g., n_sig_dig=7. For more information about the binning, see
556556
util.interpolation.preprocess_and_interpolate_ev().
@@ -702,7 +702,7 @@ def local_return_period(
702702
Notes
703703
-------
704704
Contrary to Impact.calc_freq_curve(), intensities are binned according to their n_sig_dig
705-
significant digits. This results in a coarser (and smoother) interpolation, and a
705+
significant digits. This results in a smoother (and coarser) interpolation, and a
706706
more stable extrapolation. To not bin the values, please use a large value for n_sig_dig,
707707
e.g., n_sig_dig=7. For more information about the binning, see
708708
climada.util.interpolation.preprocess_and_interpolate_ev().

climada/util/test/test_interpolation.py

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ def test_interpolate_ev_linear_interp(self):
3535
y_train = np.array([8.0, 4.0, 2.0])
3636
x_test = np.array([0.0, 3.0, 4.0, 6.0])
3737
np.testing.assert_allclose(
38-
u_interp.interpolate_ev(x_test, x_train, y_train),
38+
u_interp._interpolate_ev(x_test, x_train, y_train),
3939
np.array([np.nan, 4.0, 3.0, np.nan]),
4040
)
4141
np.testing.assert_allclose(
42-
u_interp.interpolate_ev(
42+
u_interp._interpolate_ev(
4343
x_test, x_train, y_train, extrapolation="extrapolate_constant"
4444
),
4545
np.array([8.0, 4.0, 3.0, np.nan]),
4646
)
4747
np.testing.assert_allclose(
48-
u_interp.interpolate_ev(
48+
u_interp._interpolate_ev(
4949
x_test,
5050
x_train,
5151
y_train,
@@ -61,13 +61,13 @@ def test_interpolate_ev_threshold_parameters(self):
6161
y_train = np.array([4.0, 1.0, 4.0])
6262
x_test = np.array([-1.0, 3.0, 4.0])
6363
np.testing.assert_allclose(
64-
u_interp.interpolate_ev(
64+
u_interp._interpolate_ev(
6565
x_test, x_train, y_train, extrapolation="extrapolate_constant"
6666
),
6767
np.array([4.0, 1.0, 2.0]),
6868
)
6969
np.testing.assert_allclose(
70-
u_interp.interpolate_ev(
70+
u_interp._interpolate_ev(
7171
x_test,
7272
x_train,
7373
y_train,
@@ -77,7 +77,7 @@ def test_interpolate_ev_threshold_parameters(self):
7777
np.array([1.0, 1.0, 2.0]),
7878
)
7979
np.testing.assert_allclose(
80-
u_interp.interpolate_ev(
80+
u_interp._interpolate_ev(
8181
x_test,
8282
x_train,
8383
y_train,
@@ -93,13 +93,13 @@ def test_interpolate_ev_scale_parameters(self):
9393
y_train = np.array([1.0, 3.0])
9494
x_test = np.array([1e0, 1e2])
9595
np.testing.assert_allclose(
96-
u_interp.interpolate_ev(
96+
u_interp._interpolate_ev(
9797
x_test, x_train, y_train, logx=True, extrapolation="extrapolate"
9898
),
9999
np.array([0.0, 2.0]),
100100
)
101101
np.testing.assert_allclose(
102-
u_interp.interpolate_ev(
102+
u_interp._interpolate_ev(
103103
x_test,
104104
x_train,
105105
y_train,
@@ -112,7 +112,7 @@ def test_interpolate_ev_scale_parameters(self):
112112
y_train = np.array([1e1, 1e3])
113113
x_test = np.array([0.0, 2.0])
114114
np.testing.assert_allclose(
115-
u_interp.interpolate_ev(
115+
u_interp._interpolate_ev(
116116
x_test, x_train, y_train, logy=True, extrapolation="extrapolate"
117117
),
118118
np.array([1e0, 1e2]),
@@ -121,7 +121,7 @@ def test_interpolate_ev_scale_parameters(self):
121121
y_train = np.array([1e1, 1e5])
122122
x_test = np.array([1e0, 1e2])
123123
np.testing.assert_allclose(
124-
u_interp.interpolate_ev(
124+
u_interp._interpolate_ev(
125125
x_test,
126126
x_train,
127127
y_train,
@@ -138,7 +138,7 @@ def test_interpolate_ev_degenerate_input(self):
138138
x_test = np.array([0.0, 2.0, 4.0])
139139
y_train = np.zeros(3)
140140
np.testing.assert_allclose(
141-
u_interp.interpolate_ev(x_test, x_train, y_train),
141+
u_interp._interpolate_ev(x_test, x_train, y_train),
142142
np.array([np.nan, 0.0, 0.0]),
143143
)
144144

@@ -148,29 +148,29 @@ def test_interpolate_ev_small_input(self):
148148
y_train = np.array([2.0])
149149
x_test = np.array([0.0, 1.0, 2.0])
150150
np.testing.assert_allclose(
151-
u_interp.interpolate_ev(
151+
u_interp._interpolate_ev(
152152
x_test, x_train, y_train, extrapolation="extrapolate"
153153
),
154154
np.array([2.0, 2.0, np.nan]),
155155
)
156156
np.testing.assert_allclose(
157-
u_interp.interpolate_ev(
157+
u_interp._interpolate_ev(
158158
x_test, x_train, y_train, extrapolation="extrapolate", y_asymptotic=0
159159
),
160160
np.array([2.0, 2.0, 0.0]),
161161
)
162162
np.testing.assert_allclose(
163-
u_interp.interpolate_ev(x_test, x_train, y_train), np.full(3, np.nan)
163+
u_interp._interpolate_ev(x_test, x_train, y_train), np.full(3, np.nan)
164164
)
165165

166166
x_train = np.array([])
167167
y_train = np.array([])
168168
x_test = np.array([0.0, 1.0, 2.0])
169169
np.testing.assert_allclose(
170-
u_interp.interpolate_ev(x_test, x_train, y_train), np.full(3, np.nan)
170+
u_interp._interpolate_ev(x_test, x_train, y_train), np.full(3, np.nan)
171171
)
172172
np.testing.assert_allclose(
173-
u_interp.interpolate_ev(
173+
u_interp._interpolate_ev(
174174
x_test,
175175
x_train,
176176
y_train,
@@ -186,11 +186,11 @@ def test_stepfunction_ev(self):
186186
y_train = np.array([8.0, 4.0, 2.0])
187187
x_test = np.array([0.0, 3.0, 4.0, 6.0])
188188
np.testing.assert_allclose(
189-
u_interp.stepfunction_ev(x_test, x_train, y_train),
189+
u_interp._stepfunction_ev(x_test, x_train, y_train),
190190
np.array([8.0, 4.0, 2.0, np.nan]),
191191
)
192192
np.testing.assert_allclose(
193-
u_interp.stepfunction_ev(x_test, x_train, y_train, y_asymptotic=0.0),
193+
u_interp._stepfunction_ev(x_test, x_train, y_train, y_asymptotic=0.0),
194194
np.array([8.0, 4.0, 2.0, 0.0]),
195195
)
196196

@@ -200,21 +200,21 @@ def test_stepfunction_ev_small_input(self):
200200
y_train = np.array([2.0])
201201
x_test = np.array([0.0, 1.0, 2.0])
202202
np.testing.assert_allclose(
203-
u_interp.stepfunction_ev(x_test, x_train, y_train),
203+
u_interp._stepfunction_ev(x_test, x_train, y_train),
204204
np.array([2.0, 2.0, np.nan]),
205205
)
206206
np.testing.assert_allclose(
207-
u_interp.stepfunction_ev(x_test, x_train, y_train, y_asymptotic=0),
207+
u_interp._stepfunction_ev(x_test, x_train, y_train, y_asymptotic=0),
208208
np.array([2.0, 2.0, 0.0]),
209209
)
210210
x_train = np.array([])
211211
y_train = np.array([])
212212
x_test = np.array([0.0, 1.0, 2.0])
213213
np.testing.assert_allclose(
214-
u_interp.stepfunction_ev(x_test, x_train, y_train), np.full(3, np.nan)
214+
u_interp._stepfunction_ev(x_test, x_train, y_train), np.full(3, np.nan)
215215
)
216216
np.testing.assert_allclose(
217-
u_interp.stepfunction_ev(x_test, x_train, y_train, y_asymptotic=0),
217+
u_interp._stepfunction_ev(x_test, x_train, y_train, y_asymptotic=0),
218218
np.zeros(3),
219219
)
220220

@@ -223,14 +223,12 @@ def test_frequency_group(self):
223223
frequency = np.ones(6)
224224
intensity = np.array([1.00001, 0.9998, 1.0, 2.0, 3.0, 3])
225225
np.testing.assert_allclose(
226-
u_interp.group_frequency(frequency, intensity, n_sig_dig=3),
226+
u_interp._group_frequency(frequency, intensity, n_sig_dig=3),
227227
([3, 1, 2], [1, 2, 3]),
228228
)
229229
np.testing.assert_allclose(
230-
u_interp.group_frequency([], [], n_sig_dig=3), ([], [])
230+
u_interp._group_frequency([], [], n_sig_dig=3), ([], [])
231231
)
232-
with self.assertRaises(ValueError):
233-
u_interp.group_frequency(frequency, intensity[::-1], n_sig_dig=3)
234232

235233
def test_round_to_sig_digits(self):
236234
array = [0.00111, 999.0, 55.5, 0.0, -1.001, -1.08]

0 commit comments

Comments
 (0)