diff options
author | njsmith <njs@pobox.com> | 2013-09-12 03:44:00 -0700 |
---|---|---|
committer | njsmith <njs@pobox.com> | 2013-09-12 03:44:00 -0700 |
commit | f297de0aafe1f627a719304a0977fa3fc26879db (patch) | |
tree | 4c8cf286c74d9559e8cb863ecfd9496c411b7dfd /numpy | |
parent | 5d2e8a0968592eb4ff6dddeb9a92326da205d779 (diff) | |
parent | 5262478f4d8b1569c1d675bcbd1806c19e4ea597 (diff) | |
download | numpy-f297de0aafe1f627a719304a0977fa3fc26879db.tar.gz |
Merge pull request #3726 from juliantaylor/dbg-fixes
Dbg fixes
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/umath/funcs.inc.src | 5 | ||||
-rw-r--r-- | numpy/core/src/umath/simd.inc.src | 6 | ||||
-rw-r--r-- | numpy/core/tests/test_umath.py | 11 |
3 files changed, 12 insertions, 10 deletions
diff --git a/numpy/core/src/umath/funcs.inc.src b/numpy/core/src/umath/funcs.inc.src index 6d46efc44..9df39e41f 100644 --- a/numpy/core/src/umath/funcs.inc.src +++ b/numpy/core/src/umath/funcs.inc.src @@ -351,6 +351,7 @@ nc_pow@c@(@ctype@ *a, @ctype@ *b, @ctype@ *r) *r = npy_cpack@c@(0., 0.); } else { + volatile @ftype@ tmp = NPY_INFINITY; /* NB: there are four complex zeros; c0 = (+-0, +-0), so that unlike * for reals, c0**p, with `p` negative is in general * ill-defined. @@ -360,8 +361,8 @@ nc_pow@c@(@ctype@ *a, @ctype@ *b, @ctype@ *r) *r = npy_cpack@c@(NPY_NAN, NPY_NAN); /* Raise invalid */ - ar = NPY_INFINITY; - ar = ar - ar; + tmp -= NPY_INFINITY; + ar = tmp; } return; } diff --git a/numpy/core/src/umath/simd.inc.src b/numpy/core/src/umath/simd.inc.src index 2f1c3055b..e1fe6c5b5 100644 --- a/numpy/core/src/umath/simd.inc.src +++ b/numpy/core/src/umath/simd.inc.src @@ -595,7 +595,7 @@ sse2_sqrt_@TYPE@(@type@ * op, @type@ * ip, const npy_intp n) LOOP_BLOCK_ALIGN_VAR(op, @type@, 16) { op[i] = @scalarf@(ip[i]); } - assert(npy_is_aligned(&op[i], 16)); + assert(n < (16 / sizeof(@type@)) || npy_is_aligned(&op[i], 16)); if (npy_is_aligned(&ip[i], 16)) { LOOP_BLOCKED(@type@, 16) { @vtype@ d = @vpre@_load_@vsuf@(&ip[i]); @@ -630,7 +630,7 @@ sse2_absolute_@TYPE@(@type@ * op, @type@ * ip, const npy_intp n) /* add 0 to clear -0.0 */ op[i] = tmp + 0; } - assert(npy_is_aligned(&op[i], 16)); + assert(n < (16 / sizeof(@type@)) || npy_is_aligned(&op[i], 16)); if (npy_is_aligned(&ip[i], 16)) { LOOP_BLOCKED(@type@, 16) { @vtype@ a = @vpre@_load_@vsuf@(&ip[i]); @@ -663,7 +663,7 @@ sse2_@kind@_@TYPE@(@type@ * ip, @type@ * op, const npy_intp n) LOOP_BLOCK_ALIGN_VAR(ip, @type@, 16) { *op = (*op @OP@ ip[i] || npy_isnan(*op)) ? *op : ip[i]; } - assert(npy_is_aligned(&ip[i], 16)); + assert(n < (16 / sizeof(@type@)) || npy_is_aligned(&ip[i], 16)); if (i + 2 * 16 / sizeof(@type@) <= n) { /* load the first elements */ @vtype@ c = @vpre@_load_@vsuf@((@type@*)&ip[i]); diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index 3706cfa81..61f084a01 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -161,12 +161,13 @@ class TestPower(TestCase): # zero power assert_complex_equal(np.power(zero, 0), one) - assert_complex_equal(np.power(zero, 0+1j), cnan) + with np.errstate(invalid="ignore"): + assert_complex_equal(np.power(zero, 0+1j), cnan) - # negative power - for p in [0.33, 0.5, 1, 1.5, 2, 3, 4, 5, 6.6]: - assert_complex_equal(np.power(zero, -p), cnan) - assert_complex_equal(np.power(zero, -1+0.2j), cnan) + # negative power + for p in [0.33, 0.5, 1, 1.5, 2, 3, 4, 5, 6.6]: + assert_complex_equal(np.power(zero, -p), cnan) + assert_complex_equal(np.power(zero, -1+0.2j), cnan) def test_fast_power(self): x = np.array([1, 2, 3], np.int16) |