File tree 2 files changed +16
-0
lines changed
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -485,6 +485,17 @@ def testExp(self):
485
485
self .assertTrue (math .isnan (math .exp (NAN )))
486
486
self .assertRaises (OverflowError , math .exp , 1000000 )
487
487
488
+ def testExp2 (self ):
489
+ self .assertRaises (TypeError , math .exp2 )
490
+ self .ftest ('exp2(-1)' , math .exp2 (- 1 ), 0.5 )
491
+ self .ftest ('exp2(0)' , math .exp2 (0 ), 1 )
492
+ self .ftest ('exp2(1)' , math .exp2 (1 ), 2 )
493
+ self .ftest ('exp2(2.3)' , math .exp2 (2.3 ), 4.924577653379665 )
494
+ self .assertEqual (math .exp2 (INF ), INF )
495
+ self .assertEqual (math .exp2 (NINF ), 0. )
496
+ self .assertTrue (math .isnan (math .exp2 (NAN )))
497
+ self .assertRaises (OverflowError , math .exp2 , 1000000 )
498
+
488
499
def testFabs (self ):
489
500
self .assertRaises (TypeError , math .fabs )
490
501
self .ftest ('fabs(-1)' , math .fabs (- 1 ), 1 )
Original file line number Diff line number Diff line change @@ -120,6 +120,11 @@ mod math {
120
120
call_math_func ! ( exp, x, vm)
121
121
}
122
122
123
+ #[ pyfunction]
124
+ fn exp2 ( x : ArgIntoFloat , vm : & VirtualMachine ) -> PyResult < f64 > {
125
+ call_math_func ! ( exp2, x, vm)
126
+ }
127
+
123
128
#[ pyfunction]
124
129
fn expm1 ( x : ArgIntoFloat , vm : & VirtualMachine ) -> PyResult < f64 > {
125
130
call_math_func ! ( exp_m1, x, vm)
You can’t perform that action at this time.
0 commit comments