Skip to content

Make constructing v3 ArraySpecs easier #105

@dstansby

Description

@dstansby

It's possible to construct a v2 ArraySpec with quite a short call:

ArraySpec(shape=(50, 50), chunks=(32, 32), dtype=np.uint16),

To create the same ArraySpec in v3 requires a much longer call:

ArraySpec(
        shape=(50, 50),
        data_type=np.uint16,
        chunk_grid=NamedConfig(
            name="regular",
            configuration={"chunk_shape": [32, 32]},
        ),
        chunk_key_encoding=NamedConfig(
            name="default", configuration={"separator": "/"}
        ),
        fill_value=0,
        codecs=[NamedConfig(name="bytes")],
    ),

It would be nice to shorten this call somehow. Options could include giving some of the parameters default, or providing some helper function to make constructing ArraySpecs easier.

My suggestions would be:

  • Add a regular_chunk_config(shape: tuple[int, ...]) -> NamedConfig helper function
  • Make codecs default to [NamedConfig(name="bytes")]
  • Possibly make chunk_key_encoding default to the config for "/"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions