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

Method test01_append

tables/tests/test_expression.py:1241–1280  ·  view source on GitHub ↗

Checking append mode in `set_output()`

(self)

Source from the content-addressed store, hash-verified

1239class AppendModeTestCase(common.TempFileMixin, common.PyTablesTestCase):
1240
1241 def test01_append(self):
1242 """Checking append mode in `set_output()`"""
1243
1244 shape = [3, 2]
1245 # Build input arrays
1246 a = np.arange(np.prod(shape), dtype="i4").reshape(shape)
1247 b = a.copy()
1248 c = a.copy()
1249 shape[1] = 0
1250 root = self.h5file.root
1251 a1 = self.h5file.create_earray(
1252 root, "a1", atom=tb.Int32Col(), shape=shape
1253 )
1254 b1 = self.h5file.create_earray(
1255 root, "b1", atom=tb.Int32Col(), shape=shape
1256 )
1257 c1 = self.h5file.create_earray(
1258 root, "c1", atom=tb.Int32Col(), shape=shape
1259 )
1260 r1 = self.h5file.create_earray(
1261 root, "r1", atom=tb.Int32Col(), shape=shape
1262 )
1263 a1.append(a)
1264 b1.append(b)
1265 c1.append(c)
1266 if not self.append:
1267 r1.append(c)
1268 # The expression
1269 expr = tb.Expr("2 * a1 + b1-c1")
1270 expr.set_output(r1, append_mode=self.append)
1271 expr.eval()
1272 r2 = eval("2 * a + b-c")
1273 if common.verbose:
1274 print("Tested shape:", shape)
1275 print("Computed expression:", repr(r1[:]), r1.dtype)
1276 print("Should look like:", repr(r2), r2.dtype)
1277 self.assertTrue(
1278 common.areArraysEqual(r1[:], r2),
1279 "Evaluate is returning a wrong value.",
1280 )
1281
1282
1283class AppendModeTrue(AppendModeTestCase):

Callers

nothing calls this directly

Calls 5

set_outputMethod · 0.95
evalMethod · 0.95
create_earrayMethod · 0.80
copyMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected