Indexing two simple columns under the same (very) nested column.
(self)
| 1580 | ) |
| 1581 | |
| 1582 | def test02b(self): |
| 1583 | """Indexing two simple columns under the same (very) nested column.""" |
| 1584 | |
| 1585 | desc = { |
| 1586 | "nested1": { |
| 1587 | "nested2": { |
| 1588 | "nested3": {"i1": tb.Int32Col(), "i2": tb.Int32Col()} |
| 1589 | } |
| 1590 | } |
| 1591 | } |
| 1592 | |
| 1593 | i1 = "nested1/nested2/nested3/i1" |
| 1594 | i2 = "nested1/nested2/nested3/i2" |
| 1595 | |
| 1596 | tbl = self.h5file.create_table( |
| 1597 | "/", "test", desc, title=self._getMethodName() |
| 1598 | ) |
| 1599 | |
| 1600 | row = tbl.row |
| 1601 | for i in range(1000): |
| 1602 | row[i1] = i |
| 1603 | row[i2] = i * 2 |
| 1604 | row.append() |
| 1605 | tbl.flush() |
| 1606 | |
| 1607 | cols = { |
| 1608 | "i1": tbl.cols.nested1.nested2.nested3.i1, |
| 1609 | "i2": tbl.cols.nested1.nested2.nested3.i2, |
| 1610 | } |
| 1611 | cols["i1"].create_index() |
| 1612 | cols["i2"].create_index() |
| 1613 | |
| 1614 | if self.reopen: |
| 1615 | self._reopen() |
| 1616 | tbl = self.h5file.root.test |
| 1617 | # Redefine the cols dictionary |
| 1618 | cols = { |
| 1619 | "i1": tbl.cols.nested1.nested2.nested3.i1, |
| 1620 | "i2": tbl.cols.nested1.nested2.nested3.i2, |
| 1621 | } |
| 1622 | |
| 1623 | i1res = [r[i1] for r in tbl.where("i1 < 10", cols)] |
| 1624 | i2res = [r[i2] for r in tbl.where("i2 < 10", cols)] |
| 1625 | |
| 1626 | if common.verbose: |
| 1627 | print("Retrieved values (i1):", i1res) |
| 1628 | print("Should look like:", list(range(10))) |
| 1629 | print("Retrieved values (i2):", i2res) |
| 1630 | print("Should look like:", list(range(0, 10, 2))) |
| 1631 | |
| 1632 | self.assertEqual( |
| 1633 | i1res, |
| 1634 | list(range(10)), |
| 1635 | "Select for nested column (i1) doesn't match.", |
| 1636 | ) |
| 1637 | self.assertEqual( |
| 1638 | i2res, |
| 1639 | list(range(0, 10, 2)), |
nothing calls this directly
no test coverage detected