Last active
March 31, 2016 20:50
-
-
Save tomkooij/a2ed7b5ef7aaaf072778c3ce5be5e4f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tables | |
import numexpr | |
FILENAME = 'test.h5' | |
class Test(tables.IsDescription): | |
a = tables.Float32Col(dflt=1, pos = 2) # single-precision | |
b = tables.Float32Col(dflt=1, pos = 2) # single-precision | |
c = tables.Float32Col(dflt=1, pos = 2) # single-precision | |
def make_table(): | |
with tables.open_file(FILENAME, "w") as data: | |
table = data.create_table(data.root, "table", Test) | |
row = table.row | |
for i in range(100): | |
row['a'] = i | |
row['b'] = 200+i | |
row['c'] = i | |
row.append() | |
table.flush() | |
if __name__ == '__main__': | |
print "tables: ", tables.__version__ | |
print "numexpr: ", numexpr.__version__ | |
print "MKL/VML: ", numexpr.get_vml_version() | |
#make_table() | |
with tables.open_file(FILENAME, "r") as data: | |
exprs = ['log10(b) < 2', 'sqrt(b) < 14', 'abs(b) < 200'] | |
for expr in exprs: | |
print expr, | |
result = data.root.table.read_where(expr) | |
if len(result) == 0: | |
print "Succes!" | |
else: | |
print "FAIL! len(result) = ", len(result['b']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment