summaryrefslogtreecommitdiff
path: root/numpy/polynomial/tests
diff options
context:
space:
mode:
authorJoachim Hereth <joachim.hereth@numberfour.eu>2018-10-21 22:18:34 +0200
committerJoachim Hereth <joachim.hereth@numberfour.eu>2018-10-21 22:18:34 +0200
commitaf6cb03920f3ae62cb8a8c871edeccbcd8609955 (patch)
tree489a19b6a5e866a2ca262e0f5b89cdc4301fb8ad /numpy/polynomial/tests
parentdb5750f6cdc2715f1c65be31f985e2cd2699d2e0 (diff)
downloadnumpy-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/polynomial/tests')
-rw-r--r--numpy/polynomial/tests/test_polynomial.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/numpy/polynomial/tests/test_polynomial.py b/numpy/polynomial/tests/test_polynomial.py
index 0c93be278..562aa904d 100644
--- a/numpy/polynomial/tests/test_polynomial.py
+++ b/numpy/polynomial/tests/test_polynomial.py
@@ -9,7 +9,7 @@ import numpy as np
import numpy.polynomial.polynomial as poly
from numpy.testing import (
assert_almost_equal, assert_raises, assert_equal, assert_,
- )
+ assert_array_equal)
def trim(x):
@@ -147,6 +147,19 @@ class TestEvaluation(object):
assert_equal(poly.polyval(x, [1, 0]).shape, dims)
assert_equal(poly.polyval(x, [1, 0, 0]).shape, dims)
+ #check masked arrays are processed correctly
+ mask = [False, True, False]
+ mx = np.ma.array([1, 2, 3], mask=mask)
+ res = np.polyval([7, 5, 3], mx)
+ assert_array_equal(res.mask, mask)
+
+ #check subtypes of ndarray are preserved
+ class C(np.ndarray):
+ pass
+
+ cx = np.array([1, 2, 3]).view(C)
+ assert_equal(type(np.polyval([2, 3, 4], cx)), C)
+
def test_polyvalfromroots(self):
# check exception for broadcasting x values over root array with
# too few dimensions