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
{{ message }}
Repository navigation
BUG: mean padding with np.pad may lead to different prepended and appended values #11216
The bug was posted on the mailing list. It boils down to the fact that np.mean with mean padding recomputes the mean from the half-padded array for the append step. Mathematically this would be OK, but in case of finite precision and near-zero means the near-zero prepended values may bias the recomputed mean in a way that prepended and appended values are different. Stripped-down example:
As you can see, the first and the last values (both of which should be the mean) differ on the order of the machine epsilon. The prepended value is the true mean of the original array, the appended value is the mean where the prepended value is also taken into account. It was decided on the mailing list that this is a bug.
@eric-wieser can you chime in on whether or not this is a bug. When developing the "single copy" pad function, I was perplexed as to why the code was written in such a way that made this possible. This would help me write a few tests for: #11358 (comment)
Activity
TST: Add regression test for numpygh-11216
hmaarrfk commentedon Sep 16, 2018
@eric-wieser can you chime in on whether or not this is a bug. When developing the "single copy" pad function, I was perplexed as to why the code was written in such a way that made this possible. This would help me write a few tests for: #11358 (comment)
adeak commentedon Sep 16, 2018
@hmaarrfk if you read the last link in my bug report you'll get your answer.
hmaarrfk commentedon Sep 16, 2018
of course...
hmaarrfk commentedon Sep 16, 2018
Force pushing really messes with github. @eric-wieser beat me to the punch by 10 hours:
xref #11961
MAINT: Rewrite numpy.pad without concatenate (gh-11358)
MAINT: Rewrite numpy.pad without concatenate (numpygh-11358)