Пример #1
0
 def test_get_table2(self):
     # test getting table2 on group2
     with tables.open_file('test.h5') as table:
         context = Hdf5Context(file_object=table,
                           path=['root', 'root.group1', 'root.group2'])
         table2 = context['table2']
         assert_equal( len(table2), 10)
         assert_equal(context.location('table2'), 'root.group2')
Пример #2
0
 def test_empty_keys2(self):
     # test empty keys
     table = tables.openFile('test.h5')
     context = Hdf5Context(file_object=table,
                           path=['root', 'root.group1', 'root.group2'])
     print 'keys (should have a lot of names):', context.keys()
     assert_not_equal(len(context.keys()), 0)
     table.close()
Пример #3
0
 def test_empty_keys1(self):
     # test empty keys
     table = tables.openFile('test.h5')
     context = Hdf5Context(file_object=table)
     assert_equal(len(context.keys()), 0)
     print 'keys (should be empty):', context.keys()
     print
     table.close()
Пример #4
0
 def test_get_array2(self):
     # test getting array2 on root.group1
     with tables.open_file('test.h5') as table:
         context = Hdf5Context(file_object=table,
                           path=['root', 'root.group1', 'root.group2'])
         array2 = context['array2']
         assert_equal( len(array2), 4)
         assert_equal( array2, [1, 2, 3, 4])
         assert_equal(context.location('array2'), 'root.group1')
Пример #5
0
 def test_get_array1(self):
     # test getting array1 on root
     with tables.open_file('test.h5') as table:
         context = Hdf5Context(file_object=table,
                           path=['root', 'root.group1', 'root.group2'])
         array1 = context['array1']
         assert_equal( len(array1), 2)
         assert_equal( array1, ['string', 'array'])
         assert_equal(context.location('array1'), 'root')
Пример #6
0
    def test_use_as_context(self):
        # Can we use the context as the namespace of a python calculation?
        from codetools.contexts.api import DataContext, MultiContext

        with tables.open_file('test.h5') as table:
            hdf_context = Hdf5Context(file_object=table,
                              path=['root', 'root.group1', 'root.group2'])
            results = DataContext()
            context = MultiContext(results, hdf_context)
            exec_('array2_plus_one = [a2 + 1 for a2 in array2]', {}, context)
            assert_equal(context['array2_plus_one'], [2, 3, 4, 5])
Пример #7
0
 def test_empty_keys2(self):
     # test empty keys
     with tables.open_file('test.h5') as table:
         context = Hdf5Context(file_object=table,
                           path=['root', 'root.group1', 'root.group2'])
         assert_not_equal(len(list(context.keys())), 0)
Пример #8
0
 def test_empty_keys1(self):
     # test empty keys
     with tables.open_file('test.h5') as table:
         context = Hdf5Context(file_object=table)
         assert_equal(len(list(context.keys())), 0)