summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Taylor <jtaylor.debian@googlemail.com>2016-08-05 00:38:56 +0200
committerJulian Taylor <jtaylor.debian@googlemail.com>2016-08-05 00:55:45 +0200
commit07800e53ea335bc64514e9b4b0a5e5711fd39684 (patch)
treee0fd8a0f751d605547eaaf008f6acb1578a983f9
parent4c415d2dbacb9117e295ad634bbe1d88de5b3ed6 (diff)
downloadpython-numpy-07800e53ea335bc64514e9b4b0a5e5711fd39684.tar.gz
python-numpy-07800e53ea335bc64514e9b4b0a5e5711fd39684.tar.bz2
python-numpy-07800e53ea335bc64514e9b4b0a5e5711fd39684.zip
BUG: fix float16 type not being called due to wrong ordering
closes gh-7897
-rw-r--r--numpy/core/code_generators/generate_umath.py1
-rw-r--r--numpy/core/src/umath/scalarmath.c.src5
-rw-r--r--numpy/linalg/tests/test_linalg.py4
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))