MCPcopy Create free account
hub / github.com/numpy/numpy / empty_like

Function empty_like

numpy/core/multiarray.py:86–150  ·  view source on GitHub ↗

empty_like(prototype, dtype=None, order='K', subok=True, shape=None) Return a new array with the same shape and type as a given array. Parameters ---------- prototype : array_like The shape and data-type of `prototype` define these same attributes of the return

(prototype, dtype=None, order=None, subok=None, shape=None)

Source from the content-addressed store, hash-verified

84
85@array_function_from_c_func_and_dispatcher(_multiarray_umath.empty_like)
86def empty_like(prototype, dtype=None, order=None, subok=None, shape=None):
87 """
88 empty_like(prototype, dtype=None, order='K', subok=True, shape=None)
89
90 Return a new array with the same shape and type as a given array.
91
92 Parameters
93 ----------
94 prototype : array_like
95 The shape and data-type of `prototype` define these same attributes
96 of the returned array.
97 dtype : data-type, optional
98 Overrides the data type of the result.
99
100 .. versionadded:: 1.6.0
101 order : {'C', 'F', 'A', or 'K'}, optional
102 Overrides the memory layout of the result. 'C' means C-order,
103 'F' means F-order, 'A' means 'F' if `prototype` is Fortran
104 contiguous, 'C' otherwise. 'K' means match the layout of `prototype`
105 as closely as possible.
106
107 .. versionadded:: 1.6.0
108 subok : bool, optional.
109 If True, then the newly created array will use the sub-class
110 type of `prototype`, otherwise it will be a base-class array. Defaults
111 to True.
112 shape : int or sequence of ints, optional.
113 Overrides the shape of the result. If order='K' and the number of
114 dimensions is unchanged, will try to keep order, otherwise,
115 order='C' is implied.
116
117 .. versionadded:: 1.17.0
118
119 Returns
120 -------
121 out : ndarray
122 Array of uninitialized (arbitrary) data with the same
123 shape and type as `prototype`.
124
125 See Also
126 --------
127 ones_like : Return an array of ones with shape and type of input.
128 zeros_like : Return an array of zeros with shape and type of input.
129 full_like : Return a new array with shape of input filled with value.
130 empty : Return a new uninitialized array.
131
132 Notes
133 -----
134 This function does *not* initialize the returned array; to do that use
135 `zeros_like` or `ones_like` instead. It may be marginally faster than
136 the functions that do set the array values.
137
138 Examples
139 --------
140 >>> a = ([1,2,3], [4,5,6]) # a is array-like
141 >>> np.empty_like(a)
142 array([[-1073741821, -1073741821, 3], # uninitialized
143 [ 0, 0, -1073741821]])

Callers 8

matrix_powerFunction · 0.90
test_emptyMethod · 0.90
test_dotMethod · 0.90
test_roundMethod · 0.90
zeros_likeFunction · 0.70
ones_likeFunction · 0.70
full_likeFunction · 0.70
rollFunction · 0.70

Calls

no outgoing calls

Tested by 3

test_emptyMethod · 0.72
test_dotMethod · 0.72
test_roundMethod · 0.72