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

Method populateFile

tables/tests/test_carray.py:42–90  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers 1

setUpMethod · 0.95

Calls 2

create_carrayMethod · 0.80
from_typeMethod · 0.45

Tested by

no test coverage detected