Open MarkR80 opened 6 years ago
For indexing into multidimensional arrays, maybe take a look at zarr (which evolved from bcolz): https://zarr.readthedocs.io/en/stable/tutorial.html#advanced-indexing
On Fri, 28 Sep 2018, 21:28 MarkR80, notifications@github.com wrote:
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 "
", line 1, in 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 "
", line 1, in 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)```
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Blosc/bcolz/issues/382, or mute the thread https://github.com/notifications/unsubscribe-auth/AAq8Qtv463vfdpcizW40cG_gEgrmitu8ks5ufoZvgaJpZM4W_rfk .
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.
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:
Results: