import tables as tb import numpy as np n, k, d = 1000000, 20, 30 ind = np.random.rand(n) < .01 ind = np.nonzero(ind)[0] print len(ind), "rows to select out of", n #for chunk in (100, 1000, 10000): with tb.openFile("test", "w") as f: a = f.createEArray('/', 'test', obj=np.random.rand(n//10, k, d), chunkshape=(1, k, d)) for _ in range(9): a.append(np.random.rand(n//10, k, d)) #print "chunk =", chunk #%timeit -r1 -n1 a[::1000,...] #print

In [68]:
import tables as tb
import numpy as np
n, k, d = 1000000, 20, 30
ind = np.random.rand(n) < .0001
ind = np.nonzero(ind)[0]
print len(ind), "rows to select out of", n
with tb.openFile("test3", "r") as f:
    a = f.root.test
    %timeit -r1 -n1 [a[i,...] for i in ind]
    %timeit -r1 -n1 [a[i,...] for i in ind]
    %timeit -r1 -n1 a[::n//100,...]
    #%timeit -r1 -n1 [a[ind,...] for i in ind]


100 rows to select out of 1000000
1 loops, best of 1: 268 ms per loop
1 loops, best of 1: 10.2 ms per loop
1 loops, best of 1: 146 ms per loop

In [23]:


In [ ]: