Skip to content

Commit ef360bf

Browse files
committed
adjust tests and pylint clean-up
adjust tests and pylint clean-up
1 parent 944f9aa commit ef360bf

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

climada/entity/impact_funcs/base.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def plot(self, axis=None, **kwargs):
9696
axis.set_xlim((self.intensity.min(), self.intensity.max()))
9797
axis.legend()
9898
return axis
99-
99+
100100
def check(self):
101101
"""Check consistent instance data.
102102
@@ -129,14 +129,14 @@ def check(self):
129129

130130
def set_step_impf(self, intensity, mdd=(0, 1), paa=(1, 1), impf_id=1):
131131

132-
""" Step function type impact function.
133-
132+
""" Step function type impact function.
133+
134134
By default, everything is destroyed above the step.
135135
Useful for high resolution modelling.
136-
136+
137137
This method modifies self (climada.entity.impact_funcs instance)
138138
by assigning an id, intensity, mdd and paa to the impact function.
139-
139+
140140
Parameters
141141
----------
142142
intensity: tuple(float, float, float)
@@ -160,11 +160,11 @@ def set_step_impf(self, intensity, mdd=(0, 1), paa=(1, 1), impf_id=1):
160160

161161
def set_sigmoid_impf(self, intensity, L, k, x0, if_id=1):
162162

163-
""" Sigmoid type impact function hinging on three parameter.
164-
165-
This type of impact function is very flexible for any sort of study,
163+
""" Sigmoid type impact function hinging on three parameter.
164+
165+
This type of impact function is very flexible for any sort of study,
166166
hazard and resolution. The sigmoid is defined as:
167-
167+
168168
.. math::
169169
f(x) = \frac{L}{1+exp^{-k(x-x0)}}
170170

climada/entity/impact_funcs/test/test_base.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,21 @@ def test_calc_mdr_pass(self):
3535
imp_fun.mdd = np.arange(0, 1, 0.1)
3636
new_inten = 17.2
3737
self.assertEqual(imp_fun.calc_mdr(new_inten), 0.029583999999999996)
38-
38+
3939
def test_set_step(self):
4040
"""Check default impact function: step function"""
41+
inten = (0, 5, 10)
4142
imp_fun = ImpactFunc()
42-
imp_fun.set_step_ImpF(5, 0, 10)
43+
imp_fun.set_step_impf(inten)
4344
self.assertTrue(np.array_equal(imp_fun.paa, np.ones(4)))
4445
self.assertTrue(np.array_equal(imp_fun.mdd, np.array([0, 0, 1, 1])))
4546
self.assertTrue(np.array_equal(imp_fun.intensity, np.array([0, 5, 5, 10])))
4647

4748
def test_set_sigmoid(self):
4849
"""Check default impact function: sigmoid function"""
50+
inten = (0, 100, 5)
4951
imp_fun = ImpactFunc()
50-
imp_fun.set_sigmoid_ImpF(50., 2., 1.0, 0, 100)
52+
imp_fun.set_sigmoid_impf(inten, L=1.0, k=2., x0=50.)
5153
self.assertTrue(np.array_equal(imp_fun.paa, np.ones(20)))
5254
self.assertEqual(imp_fun.mdd[10], 0.5)
5355
self.assertEqual(imp_fun.mdd[-1], 1.0)
@@ -57,3 +59,6 @@ def test_set_sigmoid(self):
5759
if __name__ == "__main__":
5860
TESTS = unittest.TestLoader().loadTestsFromTestCase(TestInterpolation)
5961
unittest.TextTestRunner(verbosity=2).run(TESTS)
62+
63+
64+

0 commit comments

Comments
 (0)