numpy.asfortranarray

numpy.asfortranarray(a, dtype=None) [source]

Return an array (ndim >= 1) laid out in Fortran order in memory.

Parameters
aarray_like

Input array.

dtypestr or dtype object, optional

By default, the data-type is inferred from the input data.

Returns
outndarray

The input a in Fortran, or column-major, order.

See also

ascontiguousarray

Convert input to a contiguous (C order) array.

asanyarray

Convert input to an ndarray with either row or column-major memory order.

require

Return an ndarray that satisfies requirements.

ndarray.flags

Information about the memory layout of the array.

Examples

>>> x = np.arange(6).reshape(2,3)
>>> y = np.asfortranarray(x)
>>> x.flags['F_CONTIGUOUS']
False
>>> y.flags['F_CONTIGUOUS']
True

Note: This function returns an array with at least one-dimension (1-d) so it will not preserve 0-d arrays.

© 2005–2020 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/1.18/reference/generated/numpy.asfortranarray.html