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

Method populateFile

tables/tests/test_basics.py:84–128  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

82 self.populateFile()
83
84 def populateFile(self):
85 root = self.h5file.root
86
87 # Create an array
88 self.h5file.create_array(root, "array", [1, 2], title="Array example")
89 self.h5file.create_table(
90 root, "table", {"var1": tb.IntCol()}, "Table example"
91 )
92 root._v_attrs.testattr = 41
93
94 # Create another array object
95 self.h5file.create_array(root, "anarray", [1], "Array title")
96 self.h5file.create_table(
97 root, "atable", {"var1": tb.IntCol()}, "Table title"
98 )
99
100 # Create a group object
101 group = self.h5file.create_group(root, "agroup", "Group title")
102 group._v_attrs.testattr = 42
103
104 # Create a some objects there
105 array1 = self.h5file.create_array(
106 group, "anarray1", [1, 2, 3, 4, 5, 6, 7], "Array title 1"
107 )
108 array1.attrs.testattr = 42
109 self.h5file.create_array(group, "anarray2", [2], "Array title 2")
110 self.h5file.create_table(
111 group, "atable1", {"var1": tb.IntCol()}, "Table title 1"
112 )
113 ra = np.rec.array([(1, 11, "a")], formats="u1,f4,S1")
114 self.h5file.create_table(group, "atable2", ra, "Table title 2")
115
116 # Create a lonely group in first level
117 self.h5file.create_group(root, "agroup2", "Group title 2")
118
119 # Create a new group in the second level
120 group3 = self.h5file.create_group(group, "agroup3", "Group title 3")
121
122 # Create a new group in the third level
123 self.h5file.create_group(group3, "agroup4", "Group title 4")
124
125 # Create an array in the root with the same name as one in 'agroup'
126 self.h5file.create_array(
127 root, "anarray1", [1, 2], title="Array example"
128 )
129
130 def test00_newFile(self):
131 """Checking creation of a new file."""

Callers 1

setUpMethod · 0.95

Calls 3

create_groupMethod · 0.80
create_arrayMethod · 0.45
create_tableMethod · 0.45

Tested by

no test coverage detected