-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Change default values for "domain" and "window" parameters of Polynomial
class
#24568
Comments
The conversion of the input arguments happens in Note that also It is indeed odd that one cannot create the polynomial Maybe there are cases with custom objects where the difference matters, but I could not find any examples. I tried creating something with
has output
|
Change default values for domain and window parameters for all convenience classes in numpy.polynomial, as discussed in issue numpy#24568.
* Make sure evaluation of a Polynomial respects nep50 for scalar input: ``` import numpy as np p=np.polynomial.Polynomial(np.array([1, 2], dtype=np.float32)) print(type(p(2))) # np.float64 # correct, since the domain argument is the default which maps to [-1., 1.] w=np.array([-1,1], dtype=np.float32) p=np.polynomial.Polynomial(np.array([1, 2], dtype=np.float32), domain=w, window=w) print(type(p(2))) # np.float32 (was float64 on main) ``` * Update documentation of the various polynomial classes for the updated domain and window (was changed in #24568) * Not addressed: ``` import numpy as np arr = np.polydiv(1, np.float32(1)) arr.dtype # float64 ``` The input here are polynomial coefficients, which are really an array and not a scalar. So the output type seems correct, even though `1` looks like a scalar input.
* Make sure evaluation of a Polynomial respects nep50 for scalar input: ``` import numpy as np p=np.polynomial.Polynomial(np.array([1, 2], dtype=np.float32)) print(type(p(2))) # np.float64 # correct, since the domain argument is the default which maps to [-1., 1.] w=np.array([-1,1], dtype=np.float32) p=np.polynomial.Polynomial(np.array([1, 2], dtype=np.float32), domain=w, window=w) print(type(p(2))) # np.float32 (was float64 on main) ``` * Update documentation of the various polynomial classes for the updated domain and window (was changed in numpy#24568) * Not addressed: ``` import numpy as np arr = np.polydiv(1, np.float32(1)) arr.dtype # float64 ``` The input here are polynomial coefficients, which are really an array and not a scalar. So the output type seems correct, even though `1` looks like a scalar input.
Proposed new feature or change:
The current default values for both
domain
andwindow
parameters are bothnp.array([-1, 1])
. On the other hand, if we call__init__
with 3 parameters, thendomain
andwindow
always get cast todouble
. This leads to the following behaviour:Changing the default values of the parameters
domain
andwindow
tonp.array([-1., 1.])
will increase consistency between constructorsPolynomial(coef)
andPolynomial(coef, domain, window)
.The text was updated successfully, but these errors were encountered: