From e63cc01c72a7af0eb1cf2e3ef621a0cc8be4e14a Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Wed, 25 Jan 2023 20:28:53 -0800 Subject: [PATCH] BUG: special: Fix handling of `powm1` overflow errors (#17855) --- scipy/special/boost_special_functions.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scipy/special/boost_special_functions.h b/scipy/special/boost_special_functions.h index ae825e5de388..835ccb9af2b6 100644 --- a/scipy/special/boost_special_functions.h +++ b/scipy/special/boost_special_functions.h @@ -90,7 +90,12 @@ Real powm1_wrap(Real x, Real y) z = NAN; } catch (const std::overflow_error& e) { sf_error("powm1", SF_ERROR_OVERFLOW, NULL); - z = INFINITY; + if (x > 0) { + z = INFINITY; + } + else { + z = -INFINITY; + } } catch (const std::underflow_error& e) { sf_error("powm1", SF_ERROR_UNDERFLOW, NULL); z = 0;