@@ -321,6 +321,42 @@ def test_ref_value_rp_pass(self):
321321 self .assertEqual ("USD" , ifc .unit )
322322 self .assertEqual ("1/week" , ifc .frequency_unit )
323323
324+ def test_evaluate_freq_curve (self ):
325+ """Test evaluate method of freq curve"""
326+ imp = Impact ()
327+ imp .frequency = np .ones (4 ) * 0.1
328+ imp .at_event = np .zeros (4 )
329+ imp .at_event [0 ] = 0.0
330+ imp .at_event [1 ] = 100.0
331+ imp .at_event [2 ] = 50.0
332+ imp .at_event [3 ] = 110.0
333+ imp .unit = "USD"
334+ imp .frequency_unit = "1/year"
335+
336+ ifc = imp .calc_freq_curve ()
337+ npt .assert_array_almost_equal (
338+ ifc .evaluate ([1 , 5 , 20 ], method = "stepfunction" ), [0.0 , 100.0 , 110.0 ]
339+ )
340+ npt .assert_array_almost_equal (
341+ ifc .evaluate ([1 , 5 , 20 ], method = "interpolate" ), [np .nan , 100.0 , np .nan ]
342+ )
343+ npt .assert_array_almost_equal (
344+ ifc .evaluate ([1 , 5 , 20 ], method = "extrapolate_constant" ), [0.0 , 100.0 , 110.0 ]
345+ )
346+ npt .assert_array_almost_equal (
347+ ifc .evaluate ([1 , 5 , 20 ], method = "extrapolate_constant" , bin_decimals = - 2 ),
348+ [0.0 , 100.0 , 100.0 ],
349+ )
350+ npt .assert_array_almost_equal (
351+ ifc .evaluate (
352+ [1.0 , 2.5 , 4 , 20 ],
353+ method = "extrapolate" ,
354+ log_frequency = False ,
355+ log_impact = False ,
356+ ),
357+ [- 300.0 , 0.0 , 75.0 , 115.0 ],
358+ )
359+
324360
325361class TestImpactPerYear (unittest .TestCase ):
326362 """Test calc_impact_year_set method"""
0 commit comments