nlcpy.copy

nlcpy.copy(a, order='K', subok=False)[source]

Returns an array copy of the given object.

Parameters
aarray_like

Input data.

order{‘C’, ‘F’, ‘A’, ‘K’}, optional

Controls the memory layout of the copy. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible. (Note that this function and ndarray.copy() are very similar, but have different default values for their order= arguments.)

subokbool, optional

If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (defaults to False).

Returns
arrndarray

Array interpretation of a.

Note

This is equivalent to:

>>> import nlcpy as vp
>>> a = vp.array([1, 2, 3])
>>> vp.array(a, copy=True)
array([1, 2, 3])

Examples

Create an array x, with a reference y and a copy z:

>>> import nlcpy as vp
>>> x = vp.array([1, 2, 3])
>>> y = x
>>> z = vp.copy(x)

Note that when we modify x, y changes, but not z:

>>> x[0] = 10
>>> x[0] == y[0]
array(True)
>>> x[0] == z[0]
array(False)