diff options
author | John Kirkham <kirkhamj@janelia.hhmi.org> | 2016-01-21 13:24:59 -0500 |
---|---|---|
committer | John Kirkham <kirkhamj@janelia.hhmi.org> | 2016-01-22 17:38:35 -0500 |
commit | e77b7b98df233f72a9d50934a4bf5b93c163b482 (patch) | |
tree | 463805acde049e5e4317e9ad686adde650734e36 | |
parent | d5cef016b336659a2288cefe8aa6f60cf340d35c (diff) | |
download | numpy-e77b7b98df233f72a9d50934a4bf5b93c163b482.tar.gz |
BUG: In `norm`, always cast non-floating point arrays to 64-bit floats. Otherwise, weird integer roundoff errors give faulty results in some cases.
-rw-r--r-- | numpy/linalg/linalg.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 9dc879d31..fe2031efb 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -2112,6 +2112,9 @@ def norm(x, ord=None, axis=None, keepdims=False): """ x = asarray(x) + if not issubclass(x.dtype.type, inexact): + x = x.astype(float) + # Immediately handle some default, simple, fast, and common cases. if axis is None: ndim = x.ndim |