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

Function zeros_like

numpy/array_api/_creation_functions.py:338–351  ·  view source on GitHub ↗

Array API compatible wrapper for :py:func:`np.zeros_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

336
337
338def zeros_like(
339 x: Array, /, *, dtype: Optional[Dtype] = None, device: Optional[Device] = None
340) -> Array:
341 """
342 Array API compatible wrapper for :py:func:`np.zeros_like <numpy.zeros_like>`.
343
344 See its docstring for more information.
345 """
346 from ._array_object import Array
347
348 _check_valid_dtype(dtype)
349 if device not in ["cpu", None]:
350 raise ValueError(f"Unsupported device {device!r}")
351 return Array._new(np.zeros_like(x._array, dtype=dtype))

Callers 1

test_zeros_like_errorsFunction · 0.50

Calls 2

_check_valid_dtypeFunction · 0.85
_newMethod · 0.80

Tested by 1

test_zeros_like_errorsFunction · 0.40