From 07800e53ea335bc64514e9b4b0a5e5711fd39684 Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Fri, 5 Aug 2016 00:38:56 +0200 Subject: BUG: fix float16 type not being called due to wrong ordering closes gh-7897 --- numpy/core/code_generators/generate_umath.py | 1 + numpy/core/src/umath/scalarmath.c.src | 5 +++-- numpy/linalg/tests/test_linalg.py | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py index e79cdd4a6..d44cabe72 100644 --- a/numpy/core/code_generators/generate_umath.py +++ b/numpy/core/code_generators/generate_umath.py @@ -696,6 +696,7 @@ defdict = { Ufunc(1, 1, None, docstrings.get('numpy.core.umath.sqrt'), None, + TD('e', f='sqrt', astype={'e':'f'}), TD(inexactvec), TD(inexact, f='sqrt', astype={'e':'f'}), TD(P, f='sqrt'), diff --git a/numpy/core/src/umath/scalarmath.c.src b/numpy/core/src/umath/scalarmath.c.src index c651383eb..32a77b6e9 100644 --- a/numpy/core/src/umath/scalarmath.c.src +++ b/numpy/core/src/umath/scalarmath.c.src @@ -1703,9 +1703,10 @@ get_functions(PyObject * mm) * generate_umath.py, the first to go into FLOAT/DOUBLE_sqrt * they have the same signature as the scalar variants so we need to skip * over them + * also skip float16 copy placed before */ - i = 4; - j = 2; + i = 6; + j = 3; while (signatures[i] != NPY_FLOAT) { i += 2; j++; } diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py index 60486d4ce..a89378acd 100644 --- a/numpy/linalg/tests/test_linalg.py +++ b/numpy/linalg/tests/test_linalg.py @@ -877,11 +877,11 @@ class _TestNorm(object): an = norm(at, 2) assert_(issubclass(an.dtype.type, np.floating)) - assert_almost_equal(an, 2.0**(1.0/2.0)) + assert_almost_equal(an, an.dtype.type(2.0)**an.dtype.type(1.0/2.0)) an = norm(at, 4) assert_(issubclass(an.dtype.type, np.floating)) - assert_almost_equal(an, 2.0**(1.0/4.0)) + assert_almost_equal(an, an.dtype.type(2.0)**an.dtype.type(1.0/4.0)) an = norm(at, np.inf) assert_(issubclass(an.dtype.type, np.floating)) -- cgit v1.2.3