-
-
Notifications
You must be signed in to change notification settings - Fork 12k
Open
Description
When a constant pad is performed the constant value is cast to the dtype of the input array. This is problematic for dtype int and constant value is float.
Reproducing code example:
import numpy as np
x = np.arange(10)
x = np.pad(x, 1, "constant", constant_values=3.3)
print(x)
x = np.arange(10)
x = np.pad(x, 1, "constant", constant_values=np.nan)
print(x)Error message:
The expected final array should have the constant value not converted to int.
Numpy/Python version information:
import sys, numpy; print(numpy.version, sys.version)
1.18.1 3.8.3 (default, May 17 2020, 18:15:42)
[GCC 10.1.0]