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

Method test02_out

tables/tests/test_expression.py:151–170  ·  view source on GitHub ↗

Checking that expression is correctly evaluated when slice is outside of data samples (`out` param)

(self)

Source from the content-addressed store, hash-verified

149 )
150
151 def test02_out(self):
152 """Checking that expression is correctly evaluated when slice is
153 outside of data samples (`out` param)"""
154 expr = tb.Expr(self.expr, self.vars)
155 # maybe it's better to use the leading dimension instead?
156 maxshape = max(self.shape)
157 start, stop, step = (maxshape + 1, maxshape + 2, None)
158 expr.set_inputs_range(start, stop, step)
159 r1 = expr.eval()
160 # create an empty array with the same dtype and shape
161 zeros = np.zeros(shape=self.shape, dtype=r1.dtype)
162 r2 = zeros[start:stop:step]
163 self.assertListEqual(r1.tolist(), r2.tolist())
164 if common.verbose:
165 print("Computed expression:", repr(r1))
166 print("Should look like:", repr(r2))
167 self.assertTrue(
168 common.areArraysEqual(r1, r2),
169 "Evaluate is returning a wrong value.",
170 )
171
172
173class ExprNumPy(ExprTestCase):

Callers

nothing calls this directly

Calls 2

set_inputs_rangeMethod · 0.95
evalMethod · 0.95

Tested by

no test coverage detected