Use numpy's function to check array is contiguous

Also set the Python exception if an error is met.