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
)
| 114 | |
| 115 | |
| 116 | def 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 | |
| 132 | def eye( |