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

Method populateFile

tables/tests/test_earray.py:39–99  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

37 self.h5file.close()
38
39 def populateFile(self):
40 group = self.rootgroup
41 obj = self.obj
42 if obj is None:
43 if self.type == "string":
44 atom = tb.StringAtom(itemsize=self.length)
45 else:
46 atom = tb.Atom.from_type(self.type)
47 else:
48 atom = None
49 title = self.__class__.__name__
50 filters = tb.Filters(
51 complevel=self.compress,
52 complib=self.complib,
53 shuffle=self.shuffle,
54 fletcher32=self.fletcher32,
55 )
56 earray = self.h5file.create_earray(
57 group,
58 "earray1",
59 atom=atom,
60 shape=self.shape,
61 title=title,
62 filters=filters,
63 expectedrows=1,
64 obj=obj,
65 )
66 earray.flavor = self.flavor
67
68 # Fill it with rows
69 self.rowshape = list(earray.shape)
70 if obj is not None:
71 self.rowshape[0] = 0
72 self.objsize = self.length
73 for i in self.rowshape:
74 if i != 0:
75 self.objsize *= i
76 self.extdim = earray.extdim
77 self.objsize *= self.chunksize
78 self.rowshape[earray.extdim] = self.chunksize
79
80 if self.type == "string":
81 object = np.ndarray(
82 buffer=b"a" * self.objsize,
83 shape=self.rowshape,
84 dtype="S%s" % earray.atom.itemsize,
85 )
86 else:
87 object = np.arange(self.objsize, dtype=earray.atom.dtype.base)
88 object.shape = self.rowshape
89
90 if common.verbose:
91 if self.flavor == "numpy":
92 print("Object to append -->", object)
93 else:
94 print("Object to append -->", repr(object))
95 for i in range(self.nappends):
96 if self.type == "string":

Callers 1

setUpMethod · 0.95

Calls 3

create_earrayMethod · 0.80
from_typeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected