Unexpected result of pyrDown

Hi everyone!

I have a question about the behaviour of pyrDown with replicated borders. In particular, with code like this:

In [14]: cv2.pyrDown(np.array([[0, 1], [0, 1]], np.float32), borderType=cv2.BORDER_REPLICATE)
Out[14]: array([[0.3125]], dtype=float32)

In [15]: cv2.pyrDown(np.array([[0, 1], [1, 0]], np.float32), borderType=cv2.BORDER_REPLICATE)
Out[15]: array([[0.4296875]], dtype=float32)

In [16]: cv2.pyrDown(np.array([[1, 0], [1, 0]], np.float32), borderType=cv2.BORDER_REPLICATE)
Out[16]: array([[0.6875]], dtype=float32)

In [17]: cv2.pyrDown(np.array([[1, 0], [0, 1]], np.float32), borderType=cv2.BORDER_REPLICATE)
Out[17]: array([[0.5703125]], dtype=float32)

In [18]: cv2.pyrDown(np.array([[1, 1], [0, 0]], np.float32), borderType=cv2.BORDER_REPLICATE)
Out[18]: array([[0.6875]], dtype=float32)

In [19]: cv2.pyrDown(np.array([[0, 0], [1, 1]], np.float32), borderType=cv2.BORDER_REPLICATE)
Out[19]: array([[0.3125]], dtype=float32)

I would expect, with such a symmetric image, to get the same result as with the default border (=0.5). Why is it not so? Thanks!

P.S. I’ve tried it with a few versions and in both C++ and Python.
P.P.S. I believe that in the previous version I used (3.4.7) this DID produce 0.5, at least my old unit tests used to pass until the upgrade.