A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.scipy.org/doc/numpy/reference/generated/numpy.ascontiguousarray.html below:

numpy.ascontiguousarray — NumPy v2.3 Manual

Starting with a Fortran-contiguous array:

>>> import numpy as np
>>> x = np.ones((2, 3), order='F')
>>> x.flags['F_CONTIGUOUS']
True

Calling ascontiguousarray makes a C-contiguous copy:

>>> y = np.ascontiguousarray(x)
>>> y.flags['C_CONTIGUOUS']
True
>>> np.may_share_memory(x, y)
False

Now, starting with a C-contiguous array:

>>> x = np.ones((2, 3), order='C')
>>> x.flags['C_CONTIGUOUS']
True

Then, calling ascontiguousarray returns the same object:

>>> y = np.ascontiguousarray(x)
>>> x is y
True

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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4