Checking nested iterators (reading, both conditions)
(self)
| 739 | self.assertEqual(result, [[0, 0], [0, 1], [1, 0], [1, 1]]) |
| 740 | |
| 741 | def test01e_readTable(self): |
| 742 | """Checking nested iterators (reading, both conditions)""" |
| 743 | |
| 744 | if common.verbose: |
| 745 | print("\n", "-=" * 30) |
| 746 | print("Running %s.test01e_readTable..." % self.__class__.__name__) |
| 747 | |
| 748 | # Create an instance of an HDF5 Table |
| 749 | self.h5file = tb.open_file(self.h5fname, "r") |
| 750 | table = self.h5file.get_node("/table0") |
| 751 | |
| 752 | # Read the records and select those with "var2" file less than 20 |
| 753 | result = [] |
| 754 | for rec in table.where("var3 < 2"): |
| 755 | for rec2 in table.where("var2 < 3"): |
| 756 | result.append([rec["var2"], rec2["var3"]]) |
| 757 | if common.verbose: |
| 758 | print("result ==>", result) |
| 759 | |
| 760 | self.assertEqual( |
| 761 | result, [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2]] |
| 762 | ) |
| 763 | |
| 764 | def test01f_readTable(self): |
| 765 | """Checking nested iterators (reading, break in the loop)""" |