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

Method test09d

tables/tests/test_indexvalues.py:1708–1816  ·  view source on GitHub ↗

Checking non-indexed where() w/ ranges, changing step (int flavor)

(self)

Source from the content-addressed store, hash-verified

1706 table1._enable_indexing_in_queries()
1707
1708 def test09d(self):
1709 """Checking non-indexed where() w/ ranges, changing step
1710 (int flavor)"""
1711
1712 if common.verbose:
1713 print("\n", "-=" * 30)
1714 print("Running %s.test09d..." % self.__class__.__name__)
1715
1716 table1 = self.h5file.root.table1
1717 table2 = self.h5file.root.table2
1718
1719 table1._disable_indexing_in_queries()
1720
1721 # Convert the limits to the appropriate type
1722 il = int(self.il)
1723 sl = int(self.sl)
1724
1725 # Do some selections and check the results
1726 t3col = table1.cols.var3
1727 self.assertIsNotNone(t3col)
1728
1729 # First selection
1730 condition = "t3col>=sl"
1731 self.assertTrue(not table1.will_query_use_indexing(condition))
1732 results1 = [
1733 p["var3"]
1734 for p in table1.where(condition, start=2, stop=-1, step=3)
1735 ]
1736 results2 = [
1737 p["var3"] for p in table2.iterrows(2, -1, 3) if p["var3"] >= sl
1738 ]
1739 # sort lists (indexing does not guarantee that rows are returned in
1740 # order)
1741 results1.sort()
1742 results2.sort()
1743 if common.verbose:
1744 print("Limits:", il, sl)
1745 print("Length results:", len(results1))
1746 print("Should be:", len(results2))
1747 self.assertEqual(len(results1), len(results2))
1748 self.assertEqual(results1, results2)
1749
1750 # Second selection
1751 condition = "t3col>=sl"
1752 self.assertTrue(not table1.will_query_use_indexing(condition))
1753 results1 = [
1754 p["var3"]
1755 for p in table1.where(condition, start=5, stop=-1, step=10)
1756 ]
1757 results2 = [
1758 p["var3"] for p in table2.iterrows(5, -1, 10) if p["var3"] >= sl
1759 ]
1760 # sort lists (indexing does not guarantee that rows are returned in
1761 # order)
1762 results1.sort()
1763 results2.sort()
1764 if common.verbose:
1765 print("Limits:", il, sl)

Callers

nothing calls this directly

Calls 5

whereMethod · 0.80
iterrowsMethod · 0.45

Tested by

no test coverage detected