Avoid using np.take(x,x); use mode='clip'