In [1]:
import tables 
import numpy as np

In [4]:
h5file = tables.open_file('tutorial.h5', mode = 'w', title = 'test file')

In [12]:
g = h5file.create_group('/', 'combinatorial_class','Combinatorial Class')

In [13]:
g


Out[13]:
/combinatorial_class (Group) 'Combinatorial Class'
  children := []

In [14]:
table = h5file.create_group(g, 'topo_class','Topological Classes')

In [15]:
g2 = table

In [19]:
class State(tables.IsDescription):
    game_number  = tables.Int64Col()
    game_hash_top = tables.Int64Col()
    game_hash_bottom = tables.Int64Col()
    red_car_end_a = tables.Int64Col()
    is_goal_state = tables.Int64Col()
    degree = tables.Int64Col()

In [21]:
tbl = h5file.create_table(g2,'game_states',State, 'Game State Example')

In [22]:
h5file


Out[22]:
File(filename=tutorial.h5, title='test file', mode='w', root_uep='/', filters=Filters(complevel=0, shuffle=False, fletcher32=False, least_significant_digit=None))
/ (RootGroup) 'test file'
/comb_class (Group) 'Combinatorial Class'
/combinatorial_class (Group) 'Combinatorial Class'
/combinatorial_class/topo_class (Group) 'Topological Classes'
/combinatorial_class/topo_class/game_states (Table(0,)) 'Game State Example'
  description := {
  "degree": Int64Col(shape=(), dflt=0, pos=0),
  "game_hash_bottom": Int64Col(shape=(), dflt=0, pos=1),
  "game_hash_top": Int64Col(shape=(), dflt=0, pos=2),
  "game_number": Int64Col(shape=(), dflt=0, pos=3),
  "is_goal_state": Int64Col(shape=(), dflt=0, pos=4),
  "red_car_end_a": Int64Col(shape=(), dflt=0, pos=5)}
  byteorder := 'little'
  chunkshape := (1365,)

In [23]:
state = tbl.row

In [25]:
for i in range(10):
    state['game_number'] = i
    state['degree'] = -1
    state['game_hash_top'] = 2394723
    state['game_hash_bottom'] = 2439233
    state['is_goal_state'] = i%2
    state['red_car_end_a'] = 16
    state.append()

In [26]:
tbl.flush()

In [29]:
tbl2 = h5file.root.combinatorial_class.topo_class.game_states

In [30]:
tbl2


Out[30]:
/combinatorial_class/topo_class/game_states (Table(10,)) 'Game State Example'
  description := {
  "degree": Int64Col(shape=(), dflt=0, pos=0),
  "game_hash_bottom": Int64Col(shape=(), dflt=0, pos=1),
  "game_hash_top": Int64Col(shape=(), dflt=0, pos=2),
  "game_number": Int64Col(shape=(), dflt=0, pos=3),
  "is_goal_state": Int64Col(shape=(), dflt=0, pos=4),
  "red_car_end_a": Int64Col(shape=(), dflt=0, pos=5)}
  byteorder := 'little'
  chunkshape := (1365,)

In [33]:
for i in tbl2.iterrows():
    print i


/combinatorial_class/topo_class/game_states.row (Row), pointing to row #0
/combinatorial_class/topo_class/game_states.row (Row), pointing to row #1
/combinatorial_class/topo_class/game_states.row (Row), pointing to row #2
/combinatorial_class/topo_class/game_states.row (Row), pointing to row #3
/combinatorial_class/topo_class/game_states.row (Row), pointing to row #4
/combinatorial_class/topo_class/game_states.row (Row), pointing to row #5
/combinatorial_class/topo_class/game_states.row (Row), pointing to row #6
/combinatorial_class/topo_class/game_states.row (Row), pointing to row #7
/combinatorial_class/topo_class/game_states.row (Row), pointing to row #8
/combinatorial_class/topo_class/game_states.row (Row), pointing to row #9

In [34]:
h5file.create_group('/','comb_class_2','Combinatorial Class - 1 car 0 trucks')


Out[34]:
/comb_class_2 (Group) 'Combinatorial Class - 1 car 0 trucks'
  children := []

In [35]:
h5file.create_group('/','comb_class_4','Combinatorial Class - 2 cars 0 trucks')


Out[35]:
/comb_class_4 (Group) 'Combinatorial Class - 2 cars 0 trucks'
  children := []

In [41]:
h5file.create_group('/comb_class_2','topo_class_28372','Topologial Class')


Out[41]:
/comb_class_2/topo_class_28372 (Group) 'Topologial Class'
  children := []

In [ ]: