I'm trying to sort a pytable according to a column, and then reverse iterate with itersorted using a negative step. This is possible according to the documentation:
http://pytables.github.io/usersguide/libref.html?highlight=itersorted#tables.Table.itersorted
However, I get the following error when I use step=-1:
OverflowError: can't convert negative value to unsigned PY_LONG_LONG
The error doesn't happen if step is positive. I have tried this with pytables 2.4 and 3.0.0b1 and both have the same problem.
Any idea why this happens? is it a bug? do I need to do something else?
I attach a minimum working example:
import tables
class IndexRecord(tables.IsDescription):
frame = tables.Int32Col(pos=1)
key = tables.StringCol(itemsize=40, pos=2)
h5 = tables.openFile("trace.h5", 'w')
index = h5.createTable(h5.root, "index", IndexRecord)
index.append([(0, 'A')])
index.append([(1, 'B')])
index.append([(3, 'C')])
index.append([(4, 'D')])
index.flush()
index.cols._f_col('frame').createCSIndex()
for row in index.itersorted('frame', step=-1): #<-crashes here!
print row['frame'], row['key']