You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
np.polymul returns an object with type np.float64 when one argument is all zero, and both arguments have type np.int64 or np.float32. Something similar happens with all zero np.complex64 giving result type np.complex128.
This doesn't happen with non-zero arguments; there the result is as expected.
This happens because polymul converts the input arrays to poly1d instances under-the-hood. The poly1d constructor has a special catch for all-zero coefficient arrays:
All that said, it's not clear what should be done about it. It would be straightforward to make np.array([0]) (see lines above) conform to the dtype of the input array, but this would be a backwards-incompatible change. Generally, user's are encouraged to use the newer np.polynomial, particularly the class-based interface (e.g. np.polynomial.Polynomial) which should (in principle) have more consistent behavior.
np.polymul
returns an object with typenp.float64
when one argument is all zero, and both arguments have typenp.int64
ornp.float32
. Something similar happens with all zeronp.complex64
giving result typenp.complex128
.This doesn't happen with non-zero arguments; there the result is as expected.
This bug isn't present in
np.convolve
.Reproducing code example:
Numpy/Python version information:
The text was updated successfully, but these errors were encountered: