Open
Description
When the array of coefficients is a masked array, the polynomial classes such as np.polynomial.Polynomial
and np.polynomial.Hermite
silently discard the mask.
For example,
In [2]: np.__version__
Out[2]: '1.19.0.dev0+5b126f8'
c
is a masked array, with c[1]
masked:
In [3]: c = np.ma.masked_array([1.0, -1.0, 3.0], mask=[0, 1, 0])
In [4]: c
Out[4]:
masked_array(data=[1.0, --, 3.0],
mask=[False, True, False],
fill_value=1e+20)
Use c
as the coefficients of a Polynomial
. The mask is ignored, resulting in the value -1 appearing in the coefficients:
In [5]: p = np.polynomial.Polynomial(c)
In [6]: p
Out[6]: Polynomial([ 1., -1., 3.], domain=[-1, 1], window=[-1, 1])