Pyhon - Best way to find the 1d center of mass in a binary numpy array,np.flatnonzero(x[:-1] != x[1:]).mean() + 0.5