Skip to content

 zarr.empty

zarr.empty

empty(shape: tuple[int, ...], **kwargs: Any) -> AnyArray

Create an empty array with the specified shape. The contents will be filled with the array's fill value or zeros if no fill value is provided.

Parameters:

  • shape (int or tuple of int) –

    Shape of the empty array.

  • **kwargs (Any, default: {} ) –

    Keyword arguments passed to create.

Returns:

  • Array

    The new array.

Notes

The contents of an empty Zarr array are not defined. On attempting to retrieve data from an empty Zarr array, any values may be returned, and these are not guaranteed to be stable from one access to the next.

Source code in zarr/api/synchronous.py
def empty(shape: tuple[int, ...], **kwargs: Any) -> AnyArray:
    """Create an empty array with the specified shape. The contents will be filled with the
    array's fill value or zeros if no fill value is provided.

    Parameters
    ----------
    shape : int or tuple of int
        Shape of the empty array.
    **kwargs
        Keyword arguments passed to [`create`][zarr.api.asynchronous.create].

    Returns
    -------
    Array
        The new array.

    Notes
    -----
    The contents of an empty Zarr array are not defined. On attempting to
    retrieve data from an empty Zarr array, any values may be returned,
    and these are not guaranteed to be stable from one access to the next.
    """
    return Array(sync(async_api.empty(shape, **kwargs)))