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

Method test01_maindim

tables/tests/test_expression.py:1466–1509  ·  view source on GitHub ↗

Checking the range selection for output (maindim > 0)

(self)

Source from the content-addressed store, hash-verified

1464 )
1465
1466 def test01_maindim(self):
1467 """Checking the range selection for output (maindim > 0)"""
1468
1469 shape = list(self.shape)
1470 start, stop, step = self.range_
1471 # Build input arrays
1472 a = np.arange(np.prod(shape), dtype="i4").reshape(shape)
1473 b = a.copy()
1474 r = a.copy()
1475 shape[self.maindim] = 0
1476 root = self.h5file.root
1477 a1 = self.h5file.create_earray(
1478 root, "a1", atom=tb.Int32Col(), shape=shape
1479 )
1480 b1 = self.h5file.create_earray(
1481 root, "b1", atom=tb.Int32Col(), shape=shape
1482 )
1483 r1 = self.h5file.create_earray(
1484 root, "r1", atom=tb.Int32Col(), shape=shape
1485 )
1486 a1.append(a)
1487 b1.append(b)
1488 r1.append(r)
1489 # The expression
1490 expr = tb.Expr("a1-b1-1")
1491 expr.set_output(r1)
1492 expr.set_output_range(start, stop, step)
1493 expr.eval()
1494 r2 = eval("a-b-1")
1495 lsl = tuple([slice(None)] * self.maindim)
1496 # print "lsl-->", lsl + (slice(start,stop,step),)
1497 lrange = len(range(start, stop, step))
1498 r.__setitem__(
1499 lsl + (slice(start, stop, step),),
1500 r2.__getitem__(lsl + (slice(0, lrange),)),
1501 )
1502 if common.verbose:
1503 print("Tested shape:", shape)
1504 print("Computed expression:", repr(r1[:]), r1.dtype)
1505 print("Should look like:", repr(r), r.dtype)
1506 self.assertTrue(
1507 common.areArraysEqual(r1[:], r),
1508 "Evaluate is returning a wrong value.",
1509 )
1510
1511
1512class setOutputRange0(setOutputRangeTestCase):

Callers

nothing calls this directly

Calls 8

set_outputMethod · 0.95
set_output_rangeMethod · 0.95
evalMethod · 0.95
create_earrayMethod · 0.80
copyMethod · 0.45
appendMethod · 0.45
__setitem__Method · 0.45
__getitem__Method · 0.45

Tested by

no test coverage detected