full_like

full_like(x: array, /, fill_value: int | float, *, 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[int, float]) – 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 (int or float) which is not of the same data type kind 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.