comparison utils/seriestables/test_series.py @ 226:bfe20d63f88c

Test pour cas sans index, après question de James
author fsavard
date Fri, 12 Mar 2010 09:02:40 -0500
parents 0515a8901c6a
children
comparison
equal deleted inserted replaced
225:eb78a695ad7a 226:bfe20d63f88c
62 table = h5f.getNode('/', 'validation_error') 62 table = h5f.getNode('/', 'validation_error')
63 63
64 assert compare_lists(table.cols.epoch[:], [1,1,2,2]) 64 assert compare_lists(table.cols.epoch[:], [1,1,2,2])
65 assert compare_lists(table.cols.minibatch[:], [1,2,1,2]) 65 assert compare_lists(table.cols.minibatch[:], [1,2,1,2])
66 assert compare_lists(table.cols.validation_error[:], [32.0, 30.0, 28.0, 26.0]) 66 assert compare_lists(table.cols.validation_error[:], [32.0, 30.0, 28.0, 26.0])
67
68 def test_ErrorSeries_no_index(h5f=None):
69 if not h5f:
70 h5f_path = tempfile.NamedTemporaryFile().name
71 h5f = tables.openFile(h5f_path, "w")
72
73 validation_error = series.ErrorSeries(error_name="validation_error",
74 table_name="validation_error",
75 hdf5_file=h5f,
76 # empty tuple
77 index_names=tuple(),
78 title="Validation error with no index")
79
80 # (1,1), (1,2) etc. are (epoch, minibatch) index
81 validation_error.append(tuple(), 32.0)
82 validation_error.append(tuple(), 30.0)
83 validation_error.append(tuple(), 28.0)
84 validation_error.append(tuple(), 26.0)
85
86 h5f.close()
87
88 h5f = tables.openFile(h5f_path, "r")
89
90 table = h5f.getNode('/', 'validation_error')
91
92 assert compare_lists(table.cols.validation_error[:], [32.0, 30.0, 28.0, 26.0])
93 assert not ("epoch" in dir(table.cols))
67 94
68 def test_ErrorSeries_notimestamp(h5f=None): 95 def test_ErrorSeries_notimestamp(h5f=None):
69 if not h5f: 96 if not h5f:
70 h5f_path = tempfile.NamedTemporaryFile().name 97 h5f_path = tempfile.NamedTemporaryFile().name
71 h5f = tables.openFile(h5f_path, "w") 98 h5f = tables.openFile(h5f_path, "w")