BUG: Polynomial.fit(...).window.dtype
inconsistent with Polynomial(...).dtype
#22742
Labels
Polynomial.fit(...).window.dtype
inconsistent with Polynomial(...).dtype
#22742
Describe the issue:
When using
np.polynomial.Polynomial.fit
to fit a polynomial to some data, thedtype
of thewindow
of the resultingnp.polynomial.Polynomial
is different than the one of an instance constructed directly vianp.polynomial.Polynomial
.This leads to polynomials effectively having the same window but still being incompatible because of the windows equality comparison evaluating to
False
.I locally tested modifying the dtype of
polydomain
here by settingpolydomain = np.array([-1., 1.])
which fixed the issue for me - however I have no idea if this raises other problems in other places.Reproduce the code example:
Error message:
No response
NumPy/Python version information:
1.23.5 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:36:39) [GCC 10.4.0]
Context for the issue:
Since
np.polynomial.Polynomial
can't fit constant polynomials, a wrapping fitting function has to construct some polynomials via the default constructor and others via.fit
. My work requires finding(poly_1 - poly_2)**2
which fails because of incompatible windows.This can be worked around by manually setting the windows on either instance.
The text was updated successfully, but these errors were encountered: