Skip to content

Commit 249f121

Browse files
authored
Merge pull request #2315 from hyperbora/fix-math-acosh
fix math.acosh
2 parents 525ff49 + babebf0 commit 249f121

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Lib/test/test_math.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ def testAcos(self):
260260
self.assertRaises(ValueError, math.acos, -1 - eps)
261261
self.assertTrue(math.isnan(math.acos(NAN)))
262262

263-
# TODO: RUSTPYTHON
264-
@unittest.expectedFailure
265263
def testAcosh(self):
266264
self.assertRaises(TypeError, math.acosh)
267265
self.ftest('acosh(1)', math.acosh(1), 0)

vm/src/stdlib/math.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,15 @@ fn math_radians(x: IntoPyFloat) -> f64 {
225225
}
226226

227227
// Hyperbolic functions:
228-
make_math_func!(math_acosh, acosh);
228+
fn math_acosh(x: IntoPyFloat, vm: &VirtualMachine) -> PyResult<f64> {
229+
let x = x.to_f64();
230+
if x.is_sign_negative() || x.is_zero() {
231+
Err(vm.new_value_error("math domain error".to_owned()))
232+
} else {
233+
Ok(x.acosh())
234+
}
235+
}
236+
229237
make_math_func!(math_asinh, asinh);
230238
make_math_func!(math_atanh, atanh);
231239
make_math_func!(math_cosh, cosh);

0 commit comments

Comments
 (0)