From babebf0794c982b2d8831a5b8ed60b11a40c3d55 Mon Sep 17 00:00:00 2001 From: hyperbora Date: Sat, 31 Oct 2020 00:26:18 +0900 Subject: [PATCH] fix math.acosh --- Lib/test/test_math.py | 2 -- vm/src/stdlib/math.rs | 10 +++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index a401a4a872..07da313854 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -260,8 +260,6 @@ def testAcos(self): self.assertRaises(ValueError, math.acos, -1 - eps) self.assertTrue(math.isnan(math.acos(NAN))) - # TODO: RUSTPYTHON - @unittest.expectedFailure def testAcosh(self): self.assertRaises(TypeError, math.acosh) self.ftest('acosh(1)', math.acosh(1), 0) diff --git a/vm/src/stdlib/math.rs b/vm/src/stdlib/math.rs index ca383666fc..d013035358 100644 --- a/vm/src/stdlib/math.rs +++ b/vm/src/stdlib/math.rs @@ -225,7 +225,15 @@ fn math_radians(x: IntoPyFloat) -> f64 { } // Hyperbolic functions: -make_math_func!(math_acosh, acosh); +fn math_acosh(x: IntoPyFloat, vm: &VirtualMachine) -> PyResult { + let x = x.to_f64(); + if x.is_sign_negative() || x.is_zero() { + Err(vm.new_value_error("math domain error".to_owned())) + } else { + Ok(x.acosh()) + } +} + make_math_func!(math_asinh, asinh); make_math_func!(math_atanh, atanh); make_math_func!(math_cosh, cosh);