Skip to content

nbytes_stored incorrect when dimension_separator="/" #2174

Closed

Description

@dstansby

Zarr version

2.18.2

Numcodecs version

0.13.0

Python Version

3.10.4

Operating System

macOS

Installation

conda

Description

When saving an array to disk and loading it again with dimension_separator="/", the number of stored bytes is incorrectly reported. In this case it is just reporting the size of the .zarray file.

Steps to reproduce

import numpy as np
import zarr

zarr_path = "test.zarr"
data = np.random.randint(0, 2**8, size=(64, 64, 64), dtype=np.uint8)

for dimension_separator in [".", "/"]:
    zarr.save_array(zarr_path, data, dimension_separator=dimension_separator)
    zarr_arr = zarr.open(zarr_path)
    print(f"{dimension_separator=}")
    print("nbytes_stored:", zarr_arr.nbytes_stored)
    print()
dimension_separator='.'
nbytes_stored: 262567

dimension_separator='/'
nbytes_stored: 391

Additional output

No response

Activity

  1. added
    bug
    on Sep 11, 2024
  2. changed the title [-]nbytes_stored incorrect when dimension_separator="/"[/-] [+]`nbytes_stored` incorrect when `dimension_separator="/"`[/+] on Sep 11, 2024
  3. kabilar commented on Sep 11, 2024

    @kabilar
    Contributor

    +1 Thank you, @dstansby.

  4. dstansby commented on Sep 11, 2024

    @dstansby
    ContributorAuthor

    Root cause of this is #253, but I'll leave this open as it gives a nice self contained example of the issue.

    Note that for OME-zarr the deafult separator is /, so currently zarr-python v2 will report the wrong size for all OME-zarr arrays 😱

  5. kabilar commented on Sep 11, 2024

    @kabilar
    Contributor

    I believe the Chunks initialized metadata is also incorrect. See example below.

    import numpy as np
    import zarr
    
    zarr_path = "test.zarr"
    data = np.random.randint(0, 2**8, size=(1000, 1000), dtype=np.uint8)
    
    for dimension_separator in [".", "/"]:
        zarr.save_array(zarr_path, data, chunks=(100,100), dimension_separator=dimension_separator)
        zarr_arr = zarr.open(zarr_path)
        print(f"{dimension_separator=}")
        print("nbytes_stored:", zarr_arr.nbytes_stored)
        print("nchunks_initialized:", zarr_arr.nchunks_initialized)
        print()

    Output

    dimension_separator='.'
    nbytes_stored: 1001973
    nchunks_initialized: 100
    
    dimension_separator='/'
    nbytes_stored: 373
    nchunks_initialized: 10
    
  6. added
    V2
    on Sep 13, 2024
  7. d-v-b commented on Sep 24, 2026

    @d-v-b
    Contributor

    I can't replicate this bug on v3, and v2 is EOL. closing as completed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    V2bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions