Skip to content

Scalar variables from kerchunk refs get manifest shape (1,) instead of () #966

@TomNicholas

Description

@TomNicholas

Kerchunk uses v2-style chunk key "0" for scalar variables. get_chunk_grid_shape interprets this as 1D shape (1,) instead of scalar (), because only "c" is recognized as scalar.

This causes ManifestStore.get_entry to return an ndarray instead of a string when resolving scalar chunk paths, which crashes urlparse downstream.

Reproducer

from virtualizarr.manifests.manifest import ChunkManifest

manifest = ChunkManifest(
    entries={"0": {"path": "s3://bucket/file.nc", "offset": 100, "length": 4}},
    shape=(),
)

Raises IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed

In practice this manifests when using open_virtual_dataset with loadable_variables on a file containing scalar coordinate variables (e.g. time, step).

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