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

Method test01_out

tables/tests/test_expression.py:1051–1089  ·  view source on GitHub ↗

Checking other dimensions than 0 as main dimension (out)

(self)

Source from the content-addressed store, hash-verified

1049 )
1050
1051 def test01_out(self):
1052 """Checking other dimensions than 0 as main dimension (out)"""
1053
1054 shape = list(self.shape)
1055 # Build input arrays
1056 a = np.arange(np.prod(shape), dtype="i4").reshape(shape)
1057 b = a.copy()
1058 c = a.copy()
1059 root = self.h5file.root
1060 shape[self.maindim] = 0
1061 a1 = self.h5file.create_earray(
1062 root, "a1", atom=tb.Int32Col(), shape=shape
1063 )
1064 b1 = self.h5file.create_earray(
1065 root, "b1", atom=tb.Int32Col(), shape=shape
1066 )
1067 c1 = self.h5file.create_earray(
1068 root, "c1", atom=tb.Int32Col(), shape=shape
1069 )
1070 r1 = self.h5file.create_earray(
1071 root, "r1", atom=tb.Int32Col(), shape=shape
1072 )
1073 a1.append(a)
1074 b1.append(b)
1075 c1.append(c)
1076 r1.append(c)
1077 # The expression
1078 expr = tb.Expr("2 * a1 + b1-c1")
1079 expr.set_output(r1)
1080 expr.eval()
1081 r2 = eval("2 * a + b-c")
1082 if common.verbose:
1083 print("Tested shape:", shape)
1084 print("Computed expression:", repr(r1[:]), r1.dtype)
1085 print("Should look like:", repr(r2), r2.dtype)
1086 self.assertTrue(
1087 common.areArraysEqual(r1[:], r2),
1088 "Evaluate is returning a wrong value.",
1089 )
1090
1091 def test02_diff_in_maindims(self):
1092 """Checking different main dimensions in inputs."""

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