-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
BUG: Unexpected pad value when padding an uint64 array #11027
Copy link
Copy link
Closed
Labels
Description
This seems to be an edge case, nevertheless I wanted to report this behavior. Especially because I find it kind of interesting.
Description
When padding an array of dtype uint64 there are some cases when mode "constant" doesn't append with the correct value but instead pads with 0.
Code to reproduce
>>> offset = 1024
>>> pad_value = np.uint64(-1024)
>>> x = np.zeros(5, dtype=np.uint64) - offset
>>> np.pad(x, 1, mode="constant", constant_values=pad_value)
array([ 0, 18446744073709551615, 18446744073709551615,
18446744073709551615, 18446744073709551615, 18446744073709551615,
0], dtype=uint64)Expected Result
array([18446744073709551615, 18446744073709551615, 18446744073709551615,
18446744073709551615, 18446744073709551615, 18446744073709551615,
18446744073709551615], dtype=uint64)There are some interesting observations to be made:
- This only happens for uint64 (uint32, uint16 and below are fine).
- This behavior is only visible if
offsetis in [1, 1024] and the argument ofnp.uint64inpad_valueis in [-1, -1024]. np.pad(x, 1, mode="minimum")(ormaximum) works fine, regardless ofoffset.
Platform, versions, etc.
NumPy: 1.14.2
Operating system: Manjaro 17.1.7, x86_64 Linux 4.14.36-1-MANJARO
Python version: 3.6.5 (Anaconda, [GCC 7.2.0] on linux)
I hope this is reproduce-able and not a weird quirk of my setup. Feel free to ask for further diagnostics if you can think of any.
Reactions are currently unavailable