I would consider this a bug, and think we should fix this.

On Sun, 29 Apr 2018 at 13:48 Virgil Stokes <v...@it.uu.se> wrote:

> Here is a python code snippet:
>
> # python vers. 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC
> v.1900 64 bit (AMD64)]
> import numpy as np  # numpy vers. 1.14.3
> #import matplotlib.pyplot as plt
>
> N   = 21
> amp = 10
> t   = np.linspace(0.0,N-1,N)
> arg = 2.0*np.pi/(N-1)
>
> y = amp*np.sin(arg*t)
> print('y:\n',y)
> print('mean(y): ',np.mean(y))
>
> #plt.plot(t,y)
> #plt.show()
>
> ypad = np.pad(y, (3,2),'mean')
> print('ypad:\n',ypad)
>
> When I execute this the outputs are:
>
> y:
>  [ 0.00000000e+00  3.09016994e+00  5.87785252e+00  8.09016994e+00
>   9.51056516e+00  1.00000000e+01  9.51056516e+00  8.09016994e+00
>   5.87785252e+00  3.09016994e+00  1.22464680e-15 -3.09016994e+00
>  -5.87785252e+00 -8.09016994e+00 -9.51056516e+00 -1.00000000e+01
>  -9.51056516e+00 -8.09016994e+00 -5.87785252e+00 -3.09016994e+00
>  -2.44929360e-15]
> mean(y):  -1.3778013372117948e-16
> ypad:
>  [-1.37780134e-16 -1.37780134e-16 -1.37780134e-16  0.00000000e+00
>   3.09016994e+00  5.87785252e+00  8.09016994e+00  9.51056516e+00
>   1.00000000e+01  9.51056516e+00  8.09016994e+00  5.87785252e+00
>   3.09016994e+00  1.22464680e-15 -3.09016994e+00 -5.87785252e+00
>  -8.09016994e+00 -9.51056516e+00 -1.00000000e+01 -9.51056516e+00
>  -8.09016994e+00 -5.87785252e+00 -3.09016994e+00 -2.44929360e-15
>  -7.40148683e-17 -7.40148683e-17]
>
> The left pad is correct, but the right pad is different and not the mean
> of y)  --- why?
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to