Return a new array of given shape and type, filled with `fill_value`. Parameters ---------- shape : int or sequence of ints Shape of the new array, e.g., ``(2, 3)`` or ``2``. fill_value : scalar or array_like Fill value. dtype : data-type, optional T
(shape, fill_value, dtype=None, order='C', *, device=None, like=None)
| 323 | @finalize_array_function_like |
| 324 | @set_module('numpy') |
| 325 | def full(shape, fill_value, dtype=None, order='C', *, device=None, like=None): |
| 326 | """ |
| 327 | Return a new array of given shape and type, filled with `fill_value`. |
| 328 | |
| 329 | Parameters |
| 330 | ---------- |
| 331 | shape : int or sequence of ints |
| 332 | Shape of the new array, e.g., ``(2, 3)`` or ``2``. |
| 333 | fill_value : scalar or array_like |
| 334 | Fill value. |
| 335 | dtype : data-type, optional |
| 336 | The desired data-type for the array The default, None, means |
| 337 | ``np.array(fill_value).dtype``. |
| 338 | order : {'C', 'F'}, optional |
| 339 | Whether to store multidimensional data in C- or Fortran-contiguous |
| 340 | (row- or column-wise) order in memory. |
| 341 | device : str, optional |
| 342 | The device on which to place the created array. Default: None. |
| 343 | For Array-API interoperability only, so must be ``"cpu"`` if passed. |
| 344 | |
| 345 | .. versionadded:: 2.0.0 |
| 346 | ${ARRAY_FUNCTION_LIKE} |
| 347 | |
| 348 | .. versionadded:: 1.20.0 |
| 349 | |
| 350 | Returns |
| 351 | ------- |
| 352 | out : ndarray |
| 353 | Array of `fill_value` with the given shape, dtype, and order. |
| 354 | |
| 355 | See Also |
| 356 | -------- |
| 357 | full_like : Return a new array with shape of input filled with value. |
| 358 | empty : Return a new uninitialized array. |
| 359 | ones : Return a new array setting values to one. |
| 360 | zeros : Return a new array setting values to zero. |
| 361 | |
| 362 | Examples |
| 363 | -------- |
| 364 | >>> import numpy as np |
| 365 | >>> np.full((2, 2), np.inf) |
| 366 | array([[inf, inf], |
| 367 | [inf, inf]]) |
| 368 | >>> np.full((2, 2), 10) |
| 369 | array([[10, 10], |
| 370 | [10, 10]]) |
| 371 | |
| 372 | >>> np.full((2, 2), [1, 2]) |
| 373 | array([[1, 2], |
| 374 | [1, 2]]) |
| 375 | |
| 376 | """ |
| 377 | if like is not None: |
| 378 | return _full_with_like( |
| 379 | like, shape, fill_value, dtype=dtype, order=order, device=device |
| 380 | ) |
| 381 | |
| 382 | if dtype is None: |