Seems like data is only used as it's bumpy ndarray representation, I think it would make sense to cast this at the beginning of the function, might help a little bit with runtime.