bundles / numpy latest / numpy / asfortranarray
built-in
numpy:asfortranarray
Signature
asfortranarray ( a , dtype = None , * , like = None ) Summary
Return an array (ndim >= 1) laid out in Fortran order in memory.
Parameters
a: array_likeInput array.
dtype: str or dtype object, optionalBy default, the data-type is inferred from the input data.
like: array_like, optionalReference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as
likesupports the__array_function__protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument.
Returns
out: ndarrayThe input
ain Fortran, or column-major, order.
Examples
Starting with a C-contiguous array:import numpy as np x = np.ones((2, 3), order='C') x.flags['C_CONTIGUOUS']✓
y = np.asfortranarray(x) y.flags['F_CONTIGUOUS'] np.may_share_memory(x, y)✓
x = np.ones((2, 3), order='F') x.flags['F_CONTIGUOUS']✓
y = np.asfortranarray(x) x is y✓
See also
- asanyarray
Convert input to an ndarray with either row or column-major memory order.
- ascontiguousarray
Convert input to a contiguous (C order) array.
- ndarray.flags
Information about the memory layout of the array.
- require
Return an ndarray that satisfies requirements.
Aliases
-
numpy.asfortranarray