Skip to content

 zarr.open_like

zarr.open_like

open_like(
    a: ArrayLike,
    path: str,
    *,
    zarr_format: ZarrFormat | None = None,
    **kwargs: Any,
) -> AnyArray

Open a persistent array like another array.

Parameters:

  • a (Array) –

    The shape and data-type of a define these same attributes of the returned array.

  • path (str) –

    The path to the new array.

  • zarr_format ((2, 3, None), default: 2 ) –

    The zarr format of the array to open or create. If None (default), an existing array of either format is opened, and a missing one is created in the default zarr format. The zarr format of a is not inherited.

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

    Additional keyword arguments passed to open_array. If mode is omitted or None, it defaults to "a". Pass mode="r" when opening an existing array from a read-only store.

Returns:

  • Array –

    The opened array.

Source code in src/zarr/api/synchronous.py
def open_like(
    a: ArrayLike, path: str, *, zarr_format: ZarrFormat | None = None, **kwargs: Any
) -> AnyArray:
    """Open a persistent array like another array.

    Parameters
    ----------
    a : Array
        The shape and data-type of a define these same attributes of the returned array.
    path : str
        The path to the new array.
    zarr_format : {2, 3, None}, optional
        The zarr format of the array to open or create. If `None` (default), an existing
        array of either format is opened, and a missing one is created in the default zarr
        format. The zarr format of `a` is not inherited.
    **kwargs
        Additional keyword arguments passed to `open_array`.
        If `mode` is omitted or `None`, it defaults to `"a"`. Pass `mode="r"` when
        opening an existing array from a read-only store.

    Returns
    -------
    Array
        The opened array.
    """
    return Array(sync(async_api.open_like(a, path=path, zarr_format=zarr_format, **kwargs)))