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

Function empty_like

numpy/array_api/_creation_functions.py:116–129  ·  view source on GitHub ↗

Array API compatible wrapper for :py:func:`np.empty_like `. See its docstring for more information.

(
    x: Array, /, *, dtype: Optional[Dtype] = None, device: Optional[Device] = None
)

Source from the content-addressed store, hash-verified

114
115
116def empty_like(
117 x: Array, /, *, dtype: Optional[Dtype] = None, device: Optional[Device] = None
118) -> Array:
119 """
120 Array API compatible wrapper for :py:func:`np.empty_like <numpy.empty_like>`.
121
122 See its docstring for more information.
123 """
124 from ._array_object import Array
125
126 _check_valid_dtype(dtype)
127 if device not in ["cpu", None]:
128 raise ValueError(f"Unsupported device {device!r}")
129 return Array._new(np.empty_like(x._array, dtype=dtype))
130
131
132def eye(

Callers 1

test_empty_like_errorsFunction · 0.50

Calls 2

_check_valid_dtypeFunction · 0.85
_newMethod · 0.80

Tested by 1

test_empty_like_errorsFunction · 0.40