Numpy vectorized and unvectorized code results not matching for 3d array

  arrays, numpy, python, vectorization

I am trying to refactor procedural code of a numpy 3d array into it’s vectorized equivalent and the results are not matching .

import numpy as np 
arr = np.empty((16,73,144))

boolArray = np.zeros((14,73,144)) 

for k in range(1,14): 
   for j in range(0,73): 
      for i in range(0,144): 
         if (arr[k+1,j,i] == arr[k-1,j,i]): 
              boolArray[k,j,i] = True

The vectorized counterpart –

# isArrEqual is a boolean array of identical shape to boolArray 
isArrEqual = (arr[2:,:,:] == arr[0:-2,:,:])

In my real data I get 6000 true entries for the procedural code and no trues at all in the vectorized counterpart.

Where I am going wrong ?

Source: Python Questions