@@ -257,7 +257,9 @@ def test_mirr(self, values, finance_rate, reinvest_rate, expected):
257
257
@pytest .mark .parametrize (
258
258
"args, expected" ,
259
259
[
260
- ({'values' : ['-4500' , '-800' , '800' , '800' , '600' , '600' , '800' , '800' , '700' , '3000' ],
260
+ ({'values' : [
261
+ '-4500' , '-800' , '800' , '800' , '600' , '600' , '800' , '800' , '700' , '3000'
262
+ ],
261
263
'finance_rate' : '0.08' , 'reinvest_rate' : '0.055'
262
264
}, '0.066597175031553548874239618'
263
265
),
@@ -277,7 +279,11 @@ def test_mirr(self, values, finance_rate, reinvest_rate, expected):
277
279
)
278
280
def test_mirr_decimal (self , number_type , args , expected ):
279
281
values = [number_type (v ) for v in args ['values' ]]
280
- result = npf .mirr (values , number_type (args ['finance_rate' ]), number_type (args ['reinvest_rate' ]))
282
+ result = npf .mirr (
283
+ values ,
284
+ number_type (args ['finance_rate' ]),
285
+ number_type (args ['reinvest_rate' ])
286
+ )
281
287
282
288
if expected is not numpy .nan :
283
289
assert_almost_equal (result , number_type (expected ), 15 )
@@ -289,7 +295,9 @@ def test_mirr_no_real_solution_exception(self):
289
295
# have the same sign, then npf.mirr returns NoRealSolutionException
290
296
# when raise_exceptions is set to True.
291
297
val = [39000 , 30000 , 21000 , 37000 , 46000 ]
292
- assert_raises (npf .NoRealSolutionError , npf .mirr , val , 0.10 , 0.12 , raise_exceptions = True )
298
+
299
+ with pytest .raises (npf .NoRealSolutionError ):
300
+ npf .mirr (val , 0.10 , 0.12 , raise_exceptions = True )
293
301
294
302
295
303
class TestNper :
@@ -721,12 +729,15 @@ def test_irr_no_real_solution_exception(self):
721
729
# have the same sign, then npf.irr returns NoRealSolutionException
722
730
# when raise_exceptions is set to True.
723
731
cashflows = numpy .array ([40000 , 5000 , 8000 , 12000 , 30000 ])
724
- assert_raises (npf .NoRealSolutionError , npf .irr , cashflows , raise_exceptions = True )
732
+
733
+ with pytest .raises (npf .NoRealSolutionError ):
734
+ npf .irr (cashflows , raise_exceptions = True )
725
735
726
736
def test_irr_maximum_iterations_exception (self ):
727
737
# Test that if the maximum number of iterations is reached,
728
738
# then npf.irr returns IterationsExceededException
729
739
# when raise_exceptions is set to True.
730
740
cashflows = numpy .array ([- 40000 , 5000 , 8000 , 12000 , 30000 ])
731
- assert_raises (npf .IterationsExceededError , npf .irr , cashflows ,
732
- maxiter = 1 , raise_exceptions = True )
741
+
742
+ with pytest .raises (npf .IterationsExceededError ):
743
+ npf .irr (cashflows , maxiter = 1 , raise_exceptions = True )
0 commit comments