Zarr / Zarr Python
Merged upstreamCorrectnessMerged Jul 28, 2026

Let open_like create arrays by default

Fixed Zarr-Python open_like so it can create a persistent array by default when the target path does not already exist.

zarr-developers/zarr-python · #4146

Problem

zarr.api.asynchronous.open_like is intended to create or open an array using metadata copied from an existing array, but it delegated to open_array without a create-capable mode. When callers omitted mode or passed mode=None, missing targets raised ArrayNotFoundError, defeating the helper's creation path.

Approach

Defaulted open_like to mode="a" when mode is omitted or None, left explicit caller modes unchanged, updated asynchronous and synchronous docstrings, documented the read-only-store behavior, and added regression coverage for omitted mode, mode=None, and read-only stores.

Impact and scope

  • Restores the intended array-creation behavior for Zarr's open_like convenience API.
  • Keeps open_array semantics unchanged, limiting the behavioral change to the helper designed to create similar arrays.
  • Clarifies that read-only stores should use mode="r" explicitly, reducing surprising behavior for existing-array reads.

Validation

  • Regression tests cover Zarr v2 and v3 with omitted mode and mode=None.
  • Additional coverage verifies read-only stores reject the default append/create mode.
  • Merged after maintainer approval and Codecov confirmation that modified coverable lines were covered.