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

Function zeros

numpy/array_api/_creation_functions.py:319–335  ·  view source on GitHub ↗

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

(
    shape: Union[int, Tuple[int, ...]],
    *,
    dtype: Optional[Dtype] = None,
    device: Optional[Device] = None,
)

Source from the content-addressed store, hash-verified

317
318
319def zeros(
320 shape: Union[int, Tuple[int, ...]],
321 *,
322 dtype: Optional[Dtype] = None,
323 device: Optional[Device] = None,
324) -> Array:
325 """
326 Array API compatible wrapper for :py:func:`np.zeros <numpy.zeros>`.
327
328 See its docstring for more information.
329 """
330 from ._array_object import Array
331
332 _check_valid_dtype(dtype)
333 if device not in ["cpu", None]:
334 raise ValueError(f"Unsupported device {device!r}")
335 return Array._new(np.zeros(shape, dtype=dtype))
336
337
338def zeros_like(

Callers 15

test_vectorMethod · 0.90
test_matrixMethod · 0.90
zeros_likeFunction · 0.50
eyeFunction · 0.50
diagFunction · 0.50
diagflatFunction · 0.50
trilFunction · 0.50
triuFunction · 0.50
apply_along_axisFunction · 0.50
iscomplexFunction · 0.50
lstsqFunction · 0.50

Calls 2

_check_valid_dtypeFunction · 0.85
_newMethod · 0.80

Tested by 12

test_vectorMethod · 0.72
test_matrixMethod · 0.72
test_testAverage2Method · 0.40
test_isinMethod · 0.40
test_smallmaskMethod · 0.40
test_shape_argumentMethod · 0.40
test_zerosMethod · 0.40
test_put_nomaskMethod · 0.40
test_zeros_errorsFunction · 0.40