full

sparse.full(shape, fill_value, dtype=None, format='coo', order='C', *, device=None, **kwargs)[source]

Return a SparseArray of given shape and type, filled with fill_value.

Parameters:
  • shape (int or tuple of ints) – Shape of the new array, e.g., (2, 3) or 2.

  • fill_value (scalar) – Fill value.

  • dtype (data-type, optional) – The desired data-type for the array. The default, None, means np.array(fill_value).dtype.

  • format (str, optional) – A format string.

  • compressed_axes (iterable, optional) – The axes to compress if returning a GCXS array.

  • order ({'C', None}) – Values except these are not currently supported and raise a NotImplementedError.

Returns:

out – Array of fill_value with the given shape and dtype.

Return type:

SparseArray

Examples

>>> full(5, 9).todense()  
array([9, 9, 9, 9, 9])
>>> full((2, 2), 9, dtype=float).todense()  
array([[9., 9.],
       [9., 9.]])