Array API compatible wrapper for :py:func:`np.full_like `. See its docstring for more information.
(
x: Array,
/,
fill_value: Union[int, float],
*,
dtype: Optional[Dtype] = None,
device: Optional[Device] = None,
)
| 185 | |
| 186 | |
| 187 | def full_like( |
| 188 | x: Array, |
| 189 | /, |
| 190 | fill_value: Union[int, float], |
| 191 | *, |
| 192 | dtype: Optional[Dtype] = None, |
| 193 | device: Optional[Device] = None, |
| 194 | ) -> Array: |
| 195 | """ |
| 196 | Array API compatible wrapper for :py:func:`np.full_like <numpy.full_like>`. |
| 197 | |
| 198 | See its docstring for more information. |
| 199 | """ |
| 200 | from ._array_object import Array |
| 201 | |
| 202 | _check_valid_dtype(dtype) |
| 203 | if device not in ["cpu", None]: |
| 204 | raise ValueError(f"Unsupported device {device!r}") |
| 205 | res = np.full_like(x._array, fill_value, dtype=dtype) |
| 206 | if res.dtype not in _all_dtypes: |
| 207 | # This will happen if the fill value is not something that NumPy |
| 208 | # coerces to one of the acceptable dtypes. |
| 209 | raise TypeError("Invalid input to full_like") |
| 210 | return Array._new(res) |
| 211 | |
| 212 | |
| 213 | def linspace( |