Checking expressions with unaligned objects.
(self)
| 446 | class UnalignedObject(common.PyTablesTestCase): |
| 447 | |
| 448 | def test00_simple(self): |
| 449 | """Checking expressions with unaligned objects.""" |
| 450 | |
| 451 | # Build unaligned arrays |
| 452 | a0 = np.empty(10, dtype="int8") |
| 453 | a1 = np.arange(10, dtype="int32") |
| 454 | a2 = a1.copy() |
| 455 | a3 = a2.copy() |
| 456 | ra = np.rec.fromarrays([a0, a1, a2, a3]) |
| 457 | # The inputs |
| 458 | a = ra["f1"] |
| 459 | b = ra["f2"] |
| 460 | self.assertEqual(a.flags.aligned, False) |
| 461 | self.assertEqual(b.flags.aligned, False) |
| 462 | # The expression |
| 463 | sexpr = "2 * a + b" |
| 464 | expr = tb.Expr(sexpr) |
| 465 | r1 = expr.eval() |
| 466 | r2 = eval(sexpr) |
| 467 | if common.verbose: |
| 468 | print("Computed expression:", repr(r1), r1.dtype) |
| 469 | print("Should look like:", repr(r2), r2.dtype) |
| 470 | self.assertTrue( |
| 471 | common.areArraysEqual(r1, r2), |
| 472 | "Evaluate is returning a wrong value.", |
| 473 | ) |
| 474 | |
| 475 | def test01_md(self): |
| 476 | """Checking expressions with unaligned objects (MD version)""" |