0

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']
martinako
  • 2,690
  • 1
  • 25
  • 44

1 Answers1

0

This is a bug. I am reporting it now.

EDIT: There is now a fix for this issue at [1]. Hopefully, it will make it into the 3.0 release. In the future please report bugs either at [2] or pytables-users@lists.sourceforge.net Thanks!

  1. https://github.com/PyTables/PyTables/pull/253
  2. https://github.com/PyTables/PyTables/issues
Anthony Scopatz
  • 3,265
  • 2
  • 15
  • 14
  • Ok thanks. at the end I solved my problem by using itersequence and creating a sequence with the rows I want to visit, very flexible. – martinako May 12 '13 at 12:21