Merge pull request #2315 from hyperbora/fix-math-acosh

fix math.acosh
This commit is contained in:
Noah authored and GitHub committed 2020-10-30 12:03:59 -05:00
commit 249f121896
2 files changed
+9 -3

No files matched your search

-2
View File
@@ -260,8 +260,6 @@ class MathTests(unittest.TestCase):
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)
+9 -1
View File
@@ -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<f64> {
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);