MCPcopy Create free account
hub / github.com/PyTables/PyTables / populateFile

Method populateFile

tables/tests/test_tree.py:33–70  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

31 self.h5file.close()
32
33 def populateFile(self):
34 group = self.h5file.root
35 maxshort = 1 << 15
36 # maxint = 2147483647 # (2 ** 31 - 1)
37 for j in range(3):
38 # Create a table
39 table = self.h5file.create_table(
40 group,
41 "table" + str(j),
42 Record,
43 title=self.title,
44 filters=None,
45 expectedrows=self.expectedrows,
46 )
47 # Get the record object associated with the new table
48 d = table.row
49 # Fill the table
50 for i in range(self.expectedrows):
51 d["var1"] = "%04d" % (self.expectedrows - i)
52 d["var2"] = i
53 d["var3"] = i % maxshort
54 d["var4"] = float(i)
55 d["var5"] = float(i)
56 d.append() # This injects the Record values
57 # Flush the buffer for this table
58 table.flush()
59
60 # Create a couple of arrays in each group
61 var1List = [x["var1"] for x in table.iterrows()]
62 var4List = [x["var4"] for x in table.iterrows()]
63
64 self.h5file.create_array(group, "var1", var1List, "1")
65 self.h5file.create_array(group, "var4", var4List, "4")
66
67 # Create a new group (descendant of group)
68 group2 = self.h5file.create_group(group, "group" + str(j))
69 # Iterate over this new group (group2)
70 group = group2
71
72 def test00_getNode(self):
73 """Checking the File.get_node() with string node names"""

Callers 1

setUpMethod · 0.95

Calls 6

create_groupMethod · 0.80
create_tableMethod · 0.45
appendMethod · 0.45
flushMethod · 0.45
iterrowsMethod · 0.45
create_arrayMethod · 0.45

Tested by

no test coverage detected