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

Function eye

numpy/array_api/_creation_functions.py:132–151  ·  view source on GitHub ↗

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

(
    n_rows: int,
    n_cols: Optional[int] = None,
    /,
    *,
    k: int = 0,
    dtype: Optional[Dtype] = None,
    device: Optional[Device] = None,
)

Source from the content-addressed store, hash-verified

130
131
132def eye(
133 n_rows: int,
134 n_cols: Optional[int] = None,
135 /,
136 *,
137 k: int = 0,
138 dtype: Optional[Dtype] = None,
139 device: Optional[Device] = None,
140) -> Array:
141 """
142 Array API compatible wrapper for :py:func:`np.eye <numpy.eye>`.
143
144 See its docstring for more information.
145 """
146 from ._array_object import Array
147
148 _check_valid_dtype(dtype)
149 if device not in ["cpu", None]:
150 raise ValueError(f"Unsupported device {device!r}")
151 return Array._new(np.eye(n_rows, M=n_cols, k=k, dtype=dtype))
152
153
154def from_dlpack(x: object, /) -> Array:

Callers 1

test_eye_errorsFunction · 0.50

Calls 2

_check_valid_dtypeFunction · 0.85
_newMethod · 0.80

Tested by 1

test_eye_errorsFunction · 0.40