File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -485,6 +485,17 @@ def testExp(self):
485485 self .assertTrue (math .isnan (math .exp (NAN )))
486486 self .assertRaises (OverflowError , math .exp , 1000000 )
487487
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+
488499 def testFabs (self ):
489500 self .assertRaises (TypeError , math .fabs )
490501 self .ftest ('fabs(-1)' , math .fabs (- 1 ), 1 )
Original file line number Diff line number Diff line change @@ -120,6 +120,11 @@ mod math {
120120 call_math_func ! ( exp, x, vm)
121121 }
122122
123+ #[ pyfunction]
124+ fn exp2 ( x : ArgIntoFloat , vm : & VirtualMachine ) -> PyResult < f64 > {
125+ call_math_func ! ( exp2, x, vm)
126+ }
127+
123128 #[ pyfunction]
124129 fn expm1 ( x : ArgIntoFloat , vm : & VirtualMachine ) -> PyResult < f64 > {
125130 call_math_func ! ( exp_m1, x, vm)
You can’t perform that action at this time.
0 commit comments