Skip to content

Instantly share code, notes, and snippets.

@ihaque
Created May 7, 2013 07:00
Show Gist options
  • Save ihaque/5530731 to your computer and use it in GitHub Desktop.
Save ihaque/5530731 to your computer and use it in GitHub Desktop.
Demo program for pytables bug
import tables
import numpy as np
h5 = tables.openFile('test.h5', 'w')
table = h5.createTable(
h5.root, 'table',
description=np.dtype([('col', 'S16')]))
table.append([('S_%05d' % i,) for i in xrange(10)])
print " ------- Unindexed ---------"
for xx in range(11):
table.where('col < "S_%05d"' % xx)
print (xx,
len(list(table.where('col < "S_%05d"' % xx))),
len(list(table.where('col == "S_%05d"' % xx))),
len(list(table.where('col <= "S_%05d"' % xx))))
table.cols.col.createCSIndex()
print " -------- Indexed --------"
print " This should look the same as above"
for xx in range(11):
table.where('col < "S_%05d"' % xx)
print (xx,
len(list(table.where('col < "S_%05d"' % xx))),
len(list(table.where('col == "S_%05d"' % xx))),
len(list(table.where('col <= "S_%05d"' % xx))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment