8000 BUG: fix float16 type not being called due to wrong ordering by juliantaylor · Pull Request #7903 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: fix float16 type not being called due to wrong ordering #7903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions numpy/core/code_generators/generate_umath.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ def english_upper(s):
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'),
Expand Down
5 changes: 3 additions & 2 deletions numpy/core/src/umath/scalarmath.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha... Boy, that is ugly ;)

j = 3;
while (signatures[i] != NPY_FLOAT) {
i += 2; j++;
}
Expand Down
4 changes: 2 additions & 2 deletions numpy/linalg/tests/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,11 +877,11 @@ def test_vector_return_type(self):

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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiousity, is this because of accuracy, or some other reason.


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))
Expand Down
0