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

Function full

numpy/array_api/_creation_functions.py:160–184  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

158
159
160def full(
161 shape: Union[int, Tuple[int, ...]],
162 fill_value: Union[int, float],
163 *,
164 dtype: Optional[Dtype] = None,
165 device: Optional[Device] = None,
166) -> Array:
167 """
168 Array API compatible wrapper for :py:func:`np.full <numpy.full>`.
169
170 See its docstring for more information.
171 """
172 from ._array_object import Array
173
174 _check_valid_dtype(dtype)
175 if device not in ["cpu", None]:
176 raise ValueError(f"Unsupported device {device!r}")
177 if isinstance(fill_value, Array) and fill_value.ndim == 0:
178 fill_value = fill_value._array
179 res = np.full(shape, fill_value, dtype=dtype)
180 if res.dtype not in _all_dtypes:
181 # This will happen if the fill value is not something that NumPy
182 # coerces to one of the acceptable dtypes.
183 raise TypeError("Invalid input to full")
184 return Array._new(res)
185
186
187def full_like(

Callers 1

test_full_errorsFunction · 0.50

Calls 2

_check_valid_dtypeFunction · 0.85
_newMethod · 0.80

Tested by 1

test_full_errorsFunction · 0.40