File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -1063,8 +1063,6 @@ def testLog(self):
10631063 self .assertEqual (math .log (INF ), INF )
10641064 self .assertTrue (math .isnan (math .log (NAN )))
10651065
1066- # TODO: RUSTPYTHON
1067- @unittest .expectedFailure
10681066 def testLog1p (self ):
10691067 self .assertRaises (TypeError , math .log1p )
10701068 for n in [2 , 2 ** 90 , 2 ** 300 ]:
Original file line number Diff line number Diff line change @@ -145,8 +145,13 @@ mod math {
145145 }
146146
147147 #[ pyfunction]
148- fn log1p ( x : ArgIntoFloat ) -> f64 {
149- ( x. to_f64 ( ) + 1.0 ) . ln ( )
148+ fn log1p ( x : ArgIntoFloat , vm : & VirtualMachine ) -> PyResult < f64 > {
149+ let x = x. to_f64 ( ) ;
150+ if x. is_nan ( ) || x > -1.0_f64 {
151+ Ok ( ( x + 1.0_f64 ) . ln ( ) )
152+ } else {
153+ Err ( vm. new_value_error ( "math domain error" . to_owned ( ) ) )
154+ }
150155 }
151156
152157 #[ pyfunction]
You can’t perform that action at this time.
0 commit comments