Blosc/bcolz

Fancy indexing does not work with multidimensional carrays

MarkR80 opened this issue · 3 comments

Fancy indexing does not appear to work with multidimensional carrays. However, the documentation states that "all the functionality of ndarray.getitem() is supported (including fancy indexing)". How do I retrieve multiple, arbitrary elements from a multidimensional carray?

Example code with bcolz v1.2.1:

import numpy as np

x_range = np.arange(0, 10, 1)
x, y = np.meshgrid(x_range, x_range, indexing='ij')

z = x + y
z_comp = bcolz.carray(z)

index_nz = np.nonzero(z == 5)
index_arg = np.argwhere(z == 5)

print( 'Numpy nonzero:', z[index_nz] )
print( 'Bcolz nonzero:', z_comp[index_nz] )
print( 'Bcolz argument:', z_comp[index_arg] )

Results:

print( 'Numpy nonzero:', z[index_nz] )
Numpy nonzero: [5 5 5 5 5 5]

print( 'Bcolz nonzero:', z_comp[index_nz] )
Traceback (most recent call last):

  File "<ipython-input-66-4bcfef4bdb9c>", line 1, in <module>
    print( 'Bcolz nonzero:', z_comp[index_nz] )

  File "bcolz/carray_ext.pyx", line 1964, in bcolz.carray_ext.carray.__getitem__

  File "bcolz/carray_ext.pyx", line 2000, in bcolz.carray_ext.carray.__getitem__

IndexError: arrays used as indices must be integer (or boolean)


print( 'Bcolz argument:', z_comp[index_arg] )
Traceback (most recent call last):

  File "<ipython-input-67-0f3fba13b36d>", line 1, in <module>
    print( 'Bcolz argument:', z_comp[index_arg] )

  File "bcolz/carray_ext.pyx", line 2000, in bcolz.carray_ext.carray.__getitem__

IndexError: arrays used as indices must be integer (or boolean)```

Thank you for the suggestion. You may want to note in the documentation that fancy indexing is not supported for multidimensional arrays.

@alimanfoo is correct in that zarr is much better positioned for handling multidimensional arrays than bcolz is. Also, bcolz is mainly in maintenance mode (it has been underfunded for too long), so I guess zarr is a better bet for incorporating new features.