diff options
author | Joachim Hereth <joachim.hereth@numberfour.eu> | 2018-10-21 22:18:34 +0200 |
---|---|---|
committer | Joachim Hereth <joachim.hereth@numberfour.eu> | 2018-10-21 22:18:34 +0200 |
commit | af6cb03920f3ae62cb8a8c871edeccbcd8609955 (patch) | |
tree | 489a19b6a5e866a2ca262e0f5b89cdc4301fb8ad /numpy/lib/polynomial.py | |
parent | db5750f6cdc2715f1c65be31f985e2cd2699d2e0 (diff) | |
download | numpy-af6cb03920f3ae62cb8a8c871edeccbcd8609955.tar.gz |
BUG: polyval returned Non-Masked Arrays for Masked Input.
This fix will preserve subtypes of ndarray when given as input (x)
to the polyval function. In particular, the results for masked
values of a masked array will be masked.
Fixes #2477.
Diffstat (limited to 'numpy/lib/polynomial.py')
-rw-r--r-- | numpy/lib/polynomial.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index 9f3b84732..165fd1b95 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -651,6 +651,8 @@ def polyval(p, x): for polynomials of high degree the values may be inaccurate due to rounding errors. Use carefully. + If `x` is a subtype of `ndarray` the return value will be of the same type. + References ---------- .. [1] I. N. Bronshtein, K. A. Semendyayev, and K. A. Hirsch (Eng. @@ -673,7 +675,7 @@ def polyval(p, x): if isinstance(x, poly1d): y = 0 else: - x = NX.asarray(x) + x = NX.asanyarray(x) y = NX.zeros_like(x) for i in range(len(p)): y = y * x + p[i] |