zarr-python icon indicating copy to clipboard operation
zarr-python copied to clipboard

Zarrr inconsitantly returns Nans

Open taras-sereda opened this issue 3 years ago • 2 comments

Minimal, reproducible code sample, a copy-pastable example if possible

# Your code here
>>> import zarr
>>> import numpy as np
>>> path = 'example.zarr'
>>> group = zarr.open_group(path, 'r')
>>> data.info
Name               : /pred_spectrum_3
Type               : zarr.core.Array
Data type          : float32
Shape              : (80, 269819)
Chunk shape        : (80, 2500)
Order              : C
Read-only          : True
Compressor         : Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0)
Store type         : zarr.storage.DirectoryStore
No. bytes          : 86342080 (82.3M)
No. bytes stored   : 63233738 (60.3M)
Storage ratio      : 1.4
Chunks initialized : 97/108
>>> data =  group['pred_spectrum_3'][:, 253676 : 254056]
>>> np.argwhere(np.isnan(data))
array([[ 0, 10],
       [ 0, 11],
       [ 0, 12],
       [ 0, 13]])
>>> data.mean()
nan
>>> data_2 =  group['pred_spectrum_3'][:]
>>> data_2[:, 253676 : 254056].mean()
0.0

Problem description

While accessing data Zarr returns Nans inconsistently. The only difference is that data is a slice when data_2 is a whole 2d array, sliced latter. I expect both ways of accessing data should give exactly same results. What might be a reason of such undetermined behavior?

Version and installation information

Please provide the following:

  • Value of zarr.__version__ = 2.10.3
  • Value of numcodecs.__version__ = 0.6.4
  • Version of Python interpreter Python 3.9.7
  • Linux MANJARO
  • How Zarr was installed (e.g., "using pip into virtual environment", or "using conda"): Via yay package manager
yay -Qi python-zarr
Name            : python-zarr
Version         : 2.10.3-1
Description     : An implementation of chunked, compressed, N-dimensional arrays for Python
Architecture    : any
URL             : https://github.com/zarr-developers/zarr-python

Also, if you think it might be relevant, please provide the output from pip freeze or conda env export depending on which was used to install Zarr.

taras-sereda avatar Dec 23 '21 16:12 taras-sereda

Hi, I'd like to try on this issue if it's not already solved. Many thanks :)

pudasainimiraj avatar Mar 21 '22 20:03 pudasainimiraj

That'd be great, @KlokMiraj. It's not solved as far as I know, but I'd definitely suggest starting by reproducing.

joshmoore avatar Mar 23 '22 15:03 joshmoore