Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing existing array with new shape and compressor using zarr.open #484

Open
d-v-b opened this issue Oct 17, 2019 · 0 comments
Open

Comments

@d-v-b
Copy link
Contributor

d-v-b commented Oct 17, 2019

zarr,convenience.open silently ignores the compressor and shape kwargs if the array already exists:

import zarr, numcodecs, os, shutil

print(f'zarr: {zarr.__version__}')
print(f'numcodecs: {numcodecs.__version__}')
print('python: 3.7')

dirname = 'test.n5'
if os.path.exists(dirname):
    shutil.rmtree(dirname)

# create array 
arr1 = zarr.open(store=zarr.N5Store(dirname), path = 'test', shape=(3,3),compressor=None)
arr1[:] = 1
print(f'shape: {arr1.shape}, compressor: {arr1.compressor}')


# access existing array with new compressor and new shape
arr2 = zarr.open(store=zarr.N5Store(dirname), path = 'test', shape=(5,5),compressor=numcodecs.GZip(-1))
arr2[:] = 1
print(f'shape: {arr2.shape}, compressor: {arr2.compressor}')

This generates the following output:

zarr: 2.3.2
numcodecs: 0.6.3
python: 3.7
shape: (3, 3), compressor: N5ChunkWrapper(chunk_shape=(3, 3), compressor_config=None, dtype=dtype('float64'))
shape: (3, 3), compressor: N5ChunkWrapper(chunk_shape=(3, 3), compressor_config=None, dtype=dtype('float64'))

Problem description

Using zarr.convenience.open to access an existing array does not overwrite the compressor parameters or the shape of that array unless the w access mode is used (i.e. deleting the existing array). This function should either adopt the new compressor / shape or, if that is not possible, emit a warning / error that the user's input will be ignored.

Version and installation information

zarr: 2.3.2 (installed via conda)
numcodecs: 0.6.3
python: 3.7
OS: Ubuntu 18.04

@d-v-b d-v-b changed the title Compressor update Accessing existing array with new shape and compressor using zarr.open Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant