numpy.flatten(), numpy.ravel() and reshape()

  • numpy.flatten() always returns a copy. numpy.ravel() returns a view of the original array and returns a copy “only if needed”.
  • flatten() is a ndarray object function. ravel() is a library-level function. (ravel will work on a list of ndarrays)
  • reshape((-1)) gets a view too, but may not be a contiguous one.