summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorMark Wiebe <mwwiebe@gmail.com>2010-12-02 23:20:47 -0800
committerMark Wiebe <mwwiebe@gmail.com>2010-12-03 11:25:36 -0800
commit7e18eafe4480246062b3c40e3df1e90ee268181d (patch)
tree68bb5ecdf83ff5cecfccbbdde6c5793f13f01422 /numpy/core
parente2e265248d2a1f7f71d28e3d6ebebeb8eb597c71 (diff)
downloadnumpy-7e18eafe4480246062b3c40e3df1e90ee268181d.tar.gz
BUG: core: Some fixes and clean up of floating point exception code
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/include/numpy/npy_math.h10
-rw-r--r--numpy/core/include/numpy/ufuncobject.h80
-rw-r--r--numpy/core/src/npymath/halffloat.c31
-rw-r--r--numpy/core/src/npymath/ieee754.c.src119
-rw-r--r--numpy/core/src/scalarmathmodule.c.src20
-rw-r--r--numpy/core/src/umath/loops.c.src12
-rw-r--r--numpy/core/tests/test_errstate.py4
-rw-r--r--numpy/core/tests/test_half.py45
-rw-r--r--numpy/core/tests/test_numeric.py6
9 files changed, 205 insertions, 122 deletions
diff --git a/numpy/core/include/numpy/npy_math.h b/numpy/core/include/numpy/npy_math.h
index abdb34d21..ba1c50dde 100644
--- a/numpy/core/include/numpy/npy_math.h
+++ b/numpy/core/include/numpy/npy_math.h
@@ -422,4 +422,14 @@ npy_clongdouble npy_csqrtl(npy_clongdouble z);
npy_clongdouble npy_ccosl(npy_clongdouble z);
npy_clongdouble npy_csinl(npy_clongdouble z);
+/*
+ * Functions that set the floating point error
+ * status word.
+ */
+
+void npy_set_floatstatus_divbyzero(void);
+void npy_set_floatstatus_overflow(void);
+void npy_set_floatstatus_underflow(void);
+void npy_set_floatstatus_invalid(void);
+
#endif
diff --git a/numpy/core/include/numpy/ufuncobject.h b/numpy/core/include/numpy/ufuncobject.h
index 35d173cda..2c6b3f8e4 100644
--- a/numpy/core/include/numpy/ufuncobject.h
+++ b/numpy/core/include/numpy/ufuncobject.h
@@ -1,5 +1,8 @@
#ifndef Py_UFUNCOBJECT_H
#define Py_UFUNCOBJECT_H
+
+#include <numpy/npy_math.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -322,11 +325,6 @@ typedef struct _loop1d_info {
FE_UNDERFLOW | FE_INVALID); \
}
-#define generate_divbyzero_error() feraiseexcept(FE_DIVBYZERO)
-#define generate_overflow_error() feraiseexcept(FE_OVERFLOW)
-#define generate_underflow_error() feraiseexcept(FE_UNDERFLOW)
-#define generate_invalid_error() feraiseexcept(FE_INVALID)
-
#elif defined(_AIX)
#include <float.h>
@@ -334,7 +332,7 @@ typedef struct _loop1d_info {
#define UFUNC_CHECK_STATUS(ret) { \
fpflag_t fpstatus; \
- \
+ \
fpstatus = fp_read_flag(); \
ret = ((FP_DIV_BY_ZERO & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \
| ((FP_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \
@@ -343,77 +341,21 @@ typedef struct _loop1d_info {
fp_swap_flag(0); \
}
-#define generate_divbyzero_error() fp_raise_xcp(FP_DIV_BY_ZERO)
-#define generate_overflow_error() fp_raise_xcp(FP_OVERFLOW)
-#define generate_underflow_error() fp_raise_xcp(FP_UNDERFLOW)
-#define generate_invalid_error() fp_raise_xcp(FP_INVALID)
-
#else
#define NO_FLOATING_POINT_SUPPORT
#define UFUNC_CHECK_STATUS(ret) { \
- ret = 0; \
+ ret = 0; \
}
#endif
-/* These should really be altered to just set the corresponding bit
- in the floating point status flag. Need to figure out how to do that
- on all the platforms...
-*/
-
-#if !defined(generate_divbyzero_error)
-static int numeric_zero2 = 0;
-static void generate_divbyzero_error(void) {
- double dummy;
- dummy = 1./numeric_zero2;
- if (dummy) /* to prevent optimizer from eliminating expression */
- return;
- else /* should never be called */
- numeric_zero2 += 1;
- return;
-}
-#endif
-
-#if !defined(generate_overflow_error)
-static double numeric_two = 2.0;
-static void generate_overflow_error(void) {
- double dummy;
- dummy = pow(numeric_two,1000);
- if (dummy)
- return;
- else
- numeric_two += 0.1;
- return;
- return;
-}
-#endif
-
-#if !defined(generate_underflow_error)
-static double numeric_small = 1e-300;
-static void generate_underflow_error(void) {
- double dummy;
- dummy = numeric_small * 1e-300;
- if (!dummy)
- return;
- else
- numeric_small += 1e-300;
- return;
-}
-#endif
-
-#if !defined(generate_invalid_error)
-static double numeric_inv_inf = NPY_INF;
-static void generate_invalid_error(void) {
- double dummy;
- dummy = numeric_inv_inf - NPY_INF;
- if (!dummy)
- return;
- else
- numeric_inv_inf += 1.0;
- return;
-}
-#endif
+/*
+ * THESE MACROS ARE DEPRECATED.
+ * Use npy_set_floatstatus_* in the npymath library.
+ */
+#define generate_divbyzero_error() npy_set_floatstatus_divbyzero()
+#define generate_overflow_error() npy_set_floatstatus_overflow()
/* Make sure it gets defined if it isn't already */
#ifndef UFUNC_NOFPE
diff --git a/numpy/core/src/npymath/halffloat.c b/numpy/core/src/npymath/halffloat.c
index da92d3e12..79f77197b 100644
--- a/numpy/core/src/npymath/halffloat.c
+++ b/numpy/core/src/npymath/halffloat.c
@@ -77,11 +77,16 @@ npy_half npy_half_spacing(npy_half h)
npy_half ret;
npy_uint16 h_exp = h&0x7c00u;
npy_uint16 h_sig = h&0x03ffu;
- if (h_exp == 0x7c00u || h == 0x7bffu) {
+ if (h_exp == 0x7c00u) {
#if NPY_HALF_GENERATE_INVALID
- generate_invalid_error();
+ npy_set_floatstatus_invalid();
#endif
ret = NPY_HALF_NAN;
+ } else if (h == 0x7bffu) {
+#if NPY_HALF_GENERATE_OVERFLOW
+ npy_set_floatstatus_overflow();
+#endif
+ ret = NPY_HALF_PINF;
} else if ((h&0x8000u) && h_sig == 0) { /* Negative boundary case */
if (h_exp > 0x2c00u) { /* If result is normalized */
ret = h_exp - 0x2c00u;
@@ -112,7 +117,7 @@ npy_half npy_half_nextafter(npy_half x, npy_half y)
if (!npy_half_isfinite(x) || npy_half_isnan(y)) {
#if NPY_HALF_GENERATE_INVALID
- generate_invalid_error();
+ npy_set_floatstatus_invalid();
#endif
ret = NPY_HALF_NAN;
} else if (npy_half_eq_nonan(x, y)) {
@@ -134,7 +139,7 @@ npy_half npy_half_nextafter(npy_half x, npy_half y)
}
#ifdef NPY_HALF_GENERATE_OVERFLOW
if (npy_half_isinf(ret)) {
- generate_overflow_error();
+ npy_set_floatstatus_overflow();
}
#endif
@@ -255,7 +260,7 @@ npy_uint16 npy_floatbits_to_halfbits(npy_uint32 f)
} else {
/* overflow to signed inf */
#if NPY_HALF_GENERATE_OVERFLOW
- generate_overflow_error();
+ npy_set_floatstatus_overflow();
#endif
return (npy_uint16) (h_sgn + 0x7c00u);
}
@@ -271,7 +276,7 @@ npy_uint16 npy_floatbits_to_halfbits(npy_uint32 f)
#if NPY_HALF_GENERATE_UNDERFLOW
/* If f != 0, it underflowed to 0 */
if ((f&0x7fffffff) != 0) {
- generate_underflow_error();
+ npy_set_floatstatus_underflow();
}
#endif
return h_sgn;
@@ -282,7 +287,7 @@ npy_uint16 npy_floatbits_to_halfbits(npy_uint32 f)
#if NPY_HALF_GENERATE_UNDERFLOW
/* If it's not exactly represented, it underflowed */
if ((f_sig&(((npy_uint32)1 << (126 - f_exp)) - 1)) != 0) {
- generate_underflow_error();
+ npy_set_floatstatus_underflow();
}
#endif
f_sig >>= (113 - f_exp);
@@ -334,7 +339,7 @@ npy_uint16 npy_floatbits_to_halfbits(npy_uint32 f)
#if NPY_HALF_GENERATE_OVERFLOW
h_sig += h_exp;
if (h_sig == 0x7c00u) {
- generate_overflow_error();
+ npy_set_floatstatus_overflow();
}
return h_sgn + h_sig;
#else
@@ -370,7 +375,7 @@ npy_uint16 npy_doublebits_to_halfbits(npy_uint64 d)
} else {
/* overflow to signed inf */
#if NPY_HALF_GENERATE_OVERFLOW
- generate_overflow_error();
+ npy_set_floatstatus_overflow();
#endif
return h_sgn + 0x7c00u;
}
@@ -385,8 +390,8 @@ npy_uint16 npy_doublebits_to_halfbits(npy_uint64 d)
if (d_exp < 0x3e60000000000000u) {
#if NPY_HALF_GENERATE_UNDERFLOW
/* If d != 0, it underflowed to 0 */
- if ((d&0x7fffffffffffffff) != 0) {
- generate_underflow_error();
+ if ((d&0x7fffffffffffffffu) != 0) {
+ npy_set_floatstatus_underflow();
}
#endif
return h_sgn;
@@ -397,7 +402,7 @@ npy_uint16 npy_doublebits_to_halfbits(npy_uint64 d)
#if NPY_HALF_GENERATE_UNDERFLOW
/* If it's not exactly represented, it underflowed */
if ((d_sig&(((npy_uint64)1 << (1051 - d_exp)) - 1)) != 0) {
- generate_underflow_error();
+ npy_set_floatstatus_underflow();
}
#endif
d_sig >>= (1009 - d_exp);
@@ -450,7 +455,7 @@ npy_uint16 npy_doublebits_to_halfbits(npy_uint64 d)
#if NPY_HALF_GENERATE_OVERFLOW
h_sig += h_exp;
if (h_sig == 0x7c00u) {
- generate_overflow_error();
+ npy_set_floatstatus_overflow();
}
return h_sgn + h_sig;
#else
diff --git a/numpy/core/src/npymath/ieee754.c.src b/numpy/core/src/npymath/ieee754.c.src
index 8df903b2b..14d3f4a90 100644
--- a/numpy/core/src/npymath/ieee754.c.src
+++ b/numpy/core/src/npymath/ieee754.c.src
@@ -548,3 +548,122 @@ npy_longdouble npy_nextafterl(npy_longdouble x, npy_longdouble y)
return nextafterl(x, y);
}
#endif
+
+/*
+ * Functions to set the floating point status word.
+ */
+
+#if defined(sun) || defined(__BSD__) || defined(__OpenBSD__) || (defined(__FreeBSD__) && (__FreeBSD_version < 502114)) || defined(__NetBSD__)
+#include <ieeefp.h>
+
+void npy_set_floatstatus_divbyzero(void)
+{
+ fpsetsticky(FP_X_DZ);
+}
+
+void npy_set_floatstatus_overflow(void)
+{
+ fpsetsticky(FP_X_OFL);
+}
+
+void npy_set_floatstatus_underflow(void)
+{
+ fpsetsticky(FP_X_UFL);
+}
+
+void npy_set_floatstatus_invalid(void)
+{
+ fpsetsticky(FP_X_INV);
+}
+
+
+#elif defined(__GLIBC__) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__FreeBSD__) && (__FreeBSD_version >= 502114))
+
+# if defined(__GLIBC__) || defined(__APPLE__) || defined(__MINGW32__) || defined(__FreeBSD__)
+# include <fenv.h>
+# elif defined(__CYGWIN__)
+# include "fenv/fenv.c"
+# endif
+
+void npy_set_floatstatus_divbyzero(void)
+{
+ feraiseexcept(FE_DIVBYZERO);
+}
+
+void npy_set_floatstatus_overflow(void)
+{
+ feraiseexcept(FE_OVERFLOW);
+}
+
+void npy_set_floatstatus_underflow(void)
+{
+ feraiseexcept(FE_UNDERFLOW);
+}
+
+void npy_set_floatstatus_invalid(void)
+{
+ feraiseexcept(FE_INVALID);
+}
+
+#elif defined(_AIX)
+#include <float.h>
+#include <fpxcp.h>
+
+void npy_set_floatstatus_divbyzero(void)
+{
+ fp_raise_xcp(FP_DIV_BY_ZERO);
+}
+
+void npy_set_floatstatus_overflow(void)
+{
+ fp_raise_xcp(FP_OVERFLOW);
+}
+
+void npy_set_floatstatus_underflow(void)
+{
+ fp_raise_xcp(FP_UNDERFLOW);
+}
+
+void npy_set_floatstatus_invalid(void)
+{
+ fp_raise_xcp(FP_INVALID);
+}
+
+#else
+
+/*
+ * By using a volatile floating point value,
+ * the compiler is forced to actually do the requested
+ * operations because of potential concurrency.
+ *
+ * We shouldn't write multiple values to a single
+ * global here, because that would cause
+ * a race condition.
+ */
+static volatile double _npy_floatstatus_x,
+ _npy_floatstatus_zero = 0.0, _npy_floatstatus_big = 1e300,
+ _npy_floatstatus_small = 1e-300, _npy_floatstatus_inf;
+
+void npy_set_floatstatus_divbyzero(void)
+{
+ _npy_floatstatus_x = 1.0 / _npy_floatstatus_zero;
+}
+
+void npy_set_floatstatus_overflow(void)
+{
+ _npy_floatstatus_x = _npy_floatstatus_big * 1e300;
+}
+
+void npy_set_floatstatus_underflow(void)
+{
+ _npy_floatstatus_x = _npy_floatstatus_small * 1e-300;
+}
+
+void npy_set_floatstatus_invalid(void)
+{
+ _npy_floatstatus_inf = NPY_INFINITY;
+ _npy_floatstatus_x = _npy_floatstatus_inf - NPY_INFINITY;
+}
+
+#endif
+
diff --git a/numpy/core/src/scalarmathmodule.c.src b/numpy/core/src/scalarmathmodule.c.src
index 712932958..d1a66e101 100644
--- a/numpy/core/src/scalarmathmodule.c.src
+++ b/numpy/core/src/scalarmathmodule.c.src
@@ -145,7 +145,7 @@ static void
if ((*out^a) >= 0 || (*out^b) >= 0) {
return;
}
- generate_overflow_error();
+ npy_set_floatstatus_overflow();
return;
}
static void
@@ -154,7 +154,7 @@ static void
if ((*out^a) >= 0 || (*out^~b) >= 0) {
return;
}
- generate_overflow_error();
+ npy_set_floatstatus_overflow();
return;
}
/**end repeat**/
@@ -168,7 +168,7 @@ static void
if (*out >= a && *out >= b) {
return;
}
- generate_overflow_error();
+ npy_set_floatstatus_overflow();
return;
}
static void
@@ -177,7 +177,7 @@ static void
if (a >= b) {
return;
}
- generate_overflow_error();
+ npy_set_floatstatus_overflow();
return;
}
/**end repeat**/
@@ -206,7 +206,7 @@ static void
#else
if (temp > MAX_@NAME@)
#endif
- generate_overflow_error();
+ npy_set_floatstatus_overflow();
return;
}
#endif
@@ -223,7 +223,7 @@ static void
@name@_ctype_multiply(@name@ a, @name@ b, @name@ *out) {
*out = a * b;
if (@char@longlong_overflow(a, b)) {
- generate_overflow_error();
+ npy_set_floatstatus_overflow();
}
return;
}
@@ -239,12 +239,12 @@ static void
static void
@name@_ctype_divide(@name@ a, @name@ b, @name@ *out) {
if (b == 0) {
- generate_divbyzero_error();
+ npy_set_floatstatus_divbyzero();
*out = 0;
}
#if @neg@
else if (b == -1 && a < 0 && a == -a) {
- generate_overflow_error();
+ npy_set_floatstatus_overflow();
*out = a / b;
}
#endif
@@ -266,7 +266,7 @@ static void
static void
@name@_ctype_remainder(@name@ a, @name@ b, @name@ *out) {
if (a == 0 || b == 0) {
- if (b == 0) generate_divbyzero_error();
+ if (b == 0) npy_set_floatstatus_divbyzero();
*out = 0;
return;
}
@@ -450,7 +450,7 @@ static void
@name@_ctype_negative(npy_@name@ a, npy_@name@ *out)
{
#if @uns@
- generate_overflow_error();
+ npy_set_floatstatus_overflow();
#endif
*out = -a;
}
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index 0c777e464..8c98db6b7 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -795,7 +795,7 @@ NPY_NO_EXPORT void
const @s@@type@ in1 = *(@s@@type@ *)ip1;
const @s@@type@ in2 = *(@s@@type@ *)ip2;
if (in2 == 0) {
- generate_divbyzero_error();
+ npy_set_floatstatus_divbyzero();
*((@s@@type@ *)op1) = 0;
}
else {
@@ -854,10 +854,10 @@ NPY_NO_EXPORT void
* by -1 causes a SIFGPE (division overflow). We treat this case here
* (to avoid a SIGFPE crash at python level), but a good solution would
* be to treat integer division problems separately from FPU exceptions
- * (i.e. fixing generate_divbyzero_error()).
+ * (i.e. a different approach than npy_set_floatstatus_divbyzero()).
*/
if (in2 == 0 || (in1 == NPY_MIN_@TYPE@ && in2 == -1)) {
- generate_divbyzero_error();
+ npy_set_floatstatus_divbyzero();
*((@type@ *)op1) = 0;
}
else if (((in1 > 0) != (in2 > 0)) && (in1 % in2 != 0)) {
@@ -876,7 +876,7 @@ U@TYPE@_divide(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func
const u@type@ in1 = *(u@type@ *)ip1;
const u@type@ in2 = *(u@type@ *)ip2;
if (in2 == 0) {
- generate_divbyzero_error();
+ npy_set_floatstatus_divbyzero();
*((u@type@ *)op1) = 0;
}
else {
@@ -892,7 +892,7 @@ NPY_NO_EXPORT void
const @type@ in1 = *(@type@ *)ip1;
const @type@ in2 = *(@type@ *)ip2;
if (in2 == 0) {
- generate_divbyzero_error();
+ npy_set_floatstatus_divbyzero();
*((@type@ *)op1) = 0;
}
else {
@@ -915,7 +915,7 @@ U@TYPE@_remainder(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(f
const u@type@ in1 = *(u@type@ *)ip1;
const u@type@ in2 = *(u@type@ *)ip2;
if (in2 == 0) {
- generate_divbyzero_error();
+ npy_set_floatstatus_divbyzero();
*((@type@ *)op1) = 0;
}
else {
diff --git a/numpy/core/tests/test_errstate.py b/numpy/core/tests/test_errstate.py
index c8e2b708f..732bb3e93 100644
--- a/numpy/core/tests/test_errstate.py
+++ b/numpy/core/tests/test_errstate.py
@@ -25,7 +25,7 @@ class TestErrstate(TestCase):
except FloatingPointError:
pass
else:
- self.fail()
+ self.fail("Did not raise an invalid error")
def test_divide(self):
with errstate(all='raise', under='ignore'):
@@ -39,7 +39,7 @@ class TestErrstate(TestCase):
except FloatingPointError:
pass
else:
- self.fail()
+ self.fail("Did not raise divide by zero error")
def test_errcall(self):
def foo(*args):
diff --git a/numpy/core/tests/test_half.py b/numpy/core/tests/test_half.py
index 409e50e92..37fce6460 100644
--- a/numpy/core/tests/test_half.py
+++ b/numpy/core/tests/test_half.py
@@ -67,32 +67,37 @@ class TestHalf(TestCase):
assert_equal(i_int,j)
def test_nans_infs(self):
- # Check some of the ufuncs
- assert_equal(np.isnan(self.all_f16), np.isnan(self.all_f32))
- assert_equal(np.isinf(self.all_f16), np.isinf(self.all_f32))
- assert_equal(np.isfinite(self.all_f16), np.isfinite(self.all_f32))
- assert_equal(np.signbit(self.all_f16), np.signbit(self.all_f32))
+ oldsettings = np.seterr(all='ignore')
+ try:
+ # Check some of the ufuncs
+ assert_equal(np.isnan(self.all_f16), np.isnan(self.all_f32))
+ assert_equal(np.isinf(self.all_f16), np.isinf(self.all_f32))
+ assert_equal(np.isfinite(self.all_f16), np.isfinite(self.all_f32))
+ assert_equal(np.signbit(self.all_f16), np.signbit(self.all_f32))
+ assert_equal(np.spacing(float16(65504)), np.inf)
- # Check comparisons of all values with NaN
- nan = float16(np.nan)
+ # Check comparisons of all values with NaN
+ nan = float16(np.nan)
- assert_(not (self.all_f16 == nan).any())
- assert_(not (nan == self.all_f16).any())
+ assert_(not (self.all_f16 == nan).any())
+ assert_(not (nan == self.all_f16).any())
- assert_((self.all_f16 != nan).all())
- assert_((nan != self.all_f16).all())
+ assert_((self.all_f16 != nan).all())
+ assert_((nan != self.all_f16).all())
- assert_(not (self.all_f16 < nan).any())
- assert_(not (nan < self.all_f16).any())
+ assert_(not (self.all_f16 < nan).any())
+ assert_(not (nan < self.all_f16).any())
- assert_(not (self.all_f16 <= nan).any())
- assert_(not (nan <= self.all_f16).any())
+ assert_(not (self.all_f16 <= nan).any())
+ assert_(not (nan <= self.all_f16).any())
- assert_(not (self.all_f16 > nan).any())
- assert_(not (nan > self.all_f16).any())
+ assert_(not (self.all_f16 > nan).any())
+ assert_(not (nan > self.all_f16).any())
- assert_(not (self.all_f16 >= nan).any())
- assert_(not (nan >= self.all_f16).any())
+ assert_(not (self.all_f16 >= nan).any())
+ assert_(not (nan >= self.all_f16).any())
+ finally:
+ np.seterr(**oldsettings)
def test_half_values(self):
@@ -396,10 +401,10 @@ class TestHalf(TestCase):
float16(-65504), float16(17))
assert_raises_fpe('overflow', np.nextafter, float16(65504), float16(np.inf))
assert_raises_fpe('overflow', np.nextafter, float16(-65504), float16(-np.inf))
+ assert_raises_fpe('overflow', np.spacing, float16(65504))
# Invalid value errors
assert_raises_fpe('invalid', np.divide, float16(np.inf), float16(np.inf))
- assert_raises_fpe('invalid', np.spacing, float16(65504))
assert_raises_fpe('invalid', np.spacing, float16(np.inf))
assert_raises_fpe('invalid', np.spacing, float16(np.nan))
assert_raises_fpe('invalid', np.nextafter, float16(np.inf), float16(0))
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py
index d8f179454..f3ca44404 100644
--- a/numpy/core/tests/test_numeric.py
+++ b/numpy/core/tests/test_numeric.py
@@ -315,9 +315,13 @@ class TestFloatExceptions(TestCase):
lambda a,b:a+b, ft_max, ft_max*ft_eps)
self.assert_raises_fpe(overflow,
lambda a,b:a-b, -ft_max, ft_max*ft_eps)
+ self.assert_raises_fpe(overflow,
+ np.power, ftype(2), ftype(2**fi.nexp))
self.assert_raises_fpe(divbyzero,
lambda a,b:a/b, ftype(1), ftype(0))
self.assert_raises_fpe(invalid,
+ lambda a,b:a/b, ftype(np.inf), ftype(np.inf))
+ self.assert_raises_fpe(invalid,
lambda a,b:a/b, ftype(0), ftype(0))
self.assert_raises_fpe(invalid,
lambda a,b:a-b, ftype(np.inf), ftype(np.inf))
@@ -325,8 +329,6 @@ class TestFloatExceptions(TestCase):
lambda a,b:a+b, ftype(np.inf), ftype(-np.inf))
self.assert_raises_fpe(invalid,
lambda a,b:a*b, ftype(0), ftype(np.inf))
- self.assert_raises_fpe(overflow,
- np.power, ftype(2), ftype(2**fi.nexp))
finally:
np.seterr(**oldsettings)