diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2016-06-15 08:34:56 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-15 08:34:56 -0600 |
commit | e26738a628de0fe1897f2960708ec16e4c3177f7 (patch) | |
tree | 1eaef0e87eea8712dda48c7f28831edf99da96cd /numpy/lib/polynomial.py | |
parent | 0b3a7d90c4d362c88d25150ada4cc95f6b8bc621 (diff) | |
parent | 050f390199b098b8f1d7bf89a003573f17a690ba (diff) | |
download | numpy-e26738a628de0fe1897f2960708ec16e4c3177f7.tar.gz |
Merge pull request #4073 from endolith/patch-2
BUG: change real output checking to test if all imaginary parts are zero
Diffstat (limited to 'numpy/lib/polynomial.py')
-rw-r--r-- | numpy/lib/polynomial.py | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index c0ab80ee8..c0a1cdaed 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -15,7 +15,7 @@ import numpy.core.numeric as NX from numpy.core import (isscalar, abs, finfo, atleast_1d, hstack, dot, array, ones) from numpy.lib.twodim_base import diag, vander -from numpy.lib.function_base import trim_zeros, sort_complex +from numpy.lib.function_base import trim_zeros from numpy.lib.type_check import iscomplex, real, imag, mintypecode from numpy.linalg import eigvals, lstsq, inv @@ -145,11 +145,7 @@ def poly(seq_of_zeros): if issubclass(a.dtype.type, NX.complexfloating): # if complex roots are all complex conjugates, the roots are real. roots = NX.asarray(seq_of_zeros, complex) - pos_roots = sort_complex(NX.compress(roots.imag > 0, roots)) - neg_roots = NX.conjugate(sort_complex( - NX.compress(roots.imag < 0, roots))) - if (len(pos_roots) == len(neg_roots) and - NX.alltrue(neg_roots == pos_roots)): + if NX.all(NX.sort(roots) == NX.sort(roots.conjugate())): a = a.real.copy() return a |