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

Function full_like

numpy/array_api/_creation_functions.py:187–210  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

185
186
187def 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
213def linspace(

Callers 1

test_full_like_errorsFunction · 0.50

Calls 2

_check_valid_dtypeFunction · 0.85
_newMethod · 0.80

Tested by 1

test_full_like_errorsFunction · 0.40