numpy.ascontiguousarray¶
-
numpy.ascontiguousarray(a, dtype=None)[source]¶ Return a contiguous array (ndim >= 1) in memory (C order).
- Parameters
- aarray_like
Input array.
- dtype
stror dtype object, optional Data-type of returned array.
- Returns
See also
asfortranarrayConvert input to an ndarray with column-major memory order.
requireReturn an ndarray that satisfies requirements.
ndarray.flagsInformation about the memory layout of the array.
Examples
>>> x = np.arange(6).reshape(2,3) >>> np.ascontiguousarray(x, dtype=np.float32) array([[0., 1., 2.], [3., 4., 5.]], dtype=float32) >>> x.flags['C_CONTIGUOUS'] True
Note: This function returns an array with at least one-dimension (1-d) so it will not preserve 0-d arrays.