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

Method setUp

tables/tests/test_expression.py:196–270  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

194class MixedContainersTestCase(common.TempFileMixin, common.PyTablesTestCase):
195
196 def setUp(self):
197 super().setUp()
198
199 # The expression
200 self.expr = "2 * a*b + c**2+d**2+e-f+g"
201
202 # Create a directory in file for outputs
203 root = self.h5file.root
204 outs = self.h5file.create_group(root, "outs")
205
206 # Define the NumPy variables to be used in expression
207 N = np.prod(self.shape)
208
209 # Initial values for variables
210 a = np.arange(0, N, dtype="int32").reshape(self.shape)
211 b = np.arange(N, 2 * N, dtype="int64").reshape(self.shape)
212 c = np.arange(2 * N, 3 * N, dtype="int32").reshape(self.shape)
213 d = np.arange(3 * N, 4 * N, dtype="int32").reshape(self.shape)
214 e = np.arange(4 * N, 5 * N, dtype="int32").reshape(self.shape)
215 self.f = f = int(3) # a regular python type
216 self.g = g = np.int16(2) # a NumPy scalar type
217
218 # Original values
219 self.npvars = {"a": a, "b": b, "c": c, "d": d, "e": e, "f": f, "g": g}
220 rnda = b.copy()
221
222 # ndarray input and output
223 self.a = a
224 self.rnda = rnda
225
226 # Array input and output
227 self.b = self.h5file.create_array(root, "b", b)
228 self.rarr = self.b.copy(outs)
229
230 # CArray input and output
231 self.c = self.h5file.create_carray(
232 root, "c", atom=tb.Atom.from_dtype(c.dtype), shape=self.shape
233 )
234 self.c[:] = c
235 self.rcarr = self.c.copy(outs)
236
237 # EArray input and output
238 eshape = list(self.shape)
239 eshape[0] = 0
240 self.d = self.h5file.create_earray(
241 root, "d", atom=tb.Atom.from_dtype(d.dtype), shape=eshape
242 )
243 self.d.append(d)
244 self.rearr = self.d.copy(outs)
245
246 # Column input and output
247 rtype = {}
248 colshape = self.shape[1:]
249 for i, col in enumerate((a, b, c, d, e, rnda)):
250 rtype["f%d" % i] = tb.Col.from_sctype(col.dtype.type, colshape)
251 t = self.h5file.create_table(root, "t", rtype)
252 nrows = self.shape[0]
253 row = t.row

Callers

nothing calls this directly

Calls 11

create_groupMethod · 0.80
create_carrayMethod · 0.80
create_earrayMethod · 0.80
setUpMethod · 0.45
copyMethod · 0.45
create_arrayMethod · 0.45
from_dtypeMethod · 0.45
appendMethod · 0.45
from_sctypeMethod · 0.45
create_tableMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected