full_like

full_like(x: array, /, fill_value: bool | int | float | complex, *, dtype: dtype | None = None, device: device | None = None) array

Returns a new array filled with fill_value and having the same shape as an input array x.

Parameters:
  • x (array) – input array from which to derive the output array shape.

  • fill_value (Union[bool, int, float, complex]) – fill value.

  • dtype (Optional[dtype]) –

    output array data type. If dtype is None, the output array data type must be inferred from x. Default: None.

    Note

    If the fill_value exceeds the precision of the resolved output array data type, behavior is unspecified and, thus, implementation-defined.

    Note

    If the fill_value has a data type which is not of the same data type kind (boolean, integer, or floating-point) as the resolved output array data type (see Type Promotion Rules), behavior is unspecified and, thus, implementation-defined.

  • device (Optional[device]) – device on which to place the created array. If device is None, the output array device must be inferred from x. Default: None.

Returns:

out (array) – an array having the same shape as x and where every element is equal to fill_value.

Notes

Changed in version 2022.12: Added complex data type support.