Checking that expression is correctly evaluated when slice is outside of data samples (`out` param)
(self)
| 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 | |
| 173 | class ExprNumPy(ExprTestCase): |
nothing calls this directly
no test coverage detected