Checking repeated queries, with varying condition.
(self)
| 2783 | self.assertEqual(results1, results2) |
| 2784 | |
| 2785 | def test13f(self): |
| 2786 | """Checking repeated queries, with varying condition.""" |
| 2787 | |
| 2788 | if common.verbose: |
| 2789 | print("\n", "-=" * 30) |
| 2790 | print("Running %s.test13f..." % self.__class__.__name__) |
| 2791 | |
| 2792 | table1 = self.h5file.root.table1 |
| 2793 | table2 = self.h5file.root.table2 |
| 2794 | |
| 2795 | # Remove indexes in var2 column |
| 2796 | table1.cols.var2.remove_index() |
| 2797 | table2.cols.var2.remove_index() |
| 2798 | |
| 2799 | # Convert the limits to the appropriate type |
| 2800 | il = str(self.il).encode("ascii") |
| 2801 | sl = str(self.sl).encode("ascii") |
| 2802 | |
| 2803 | # Do some selections and check the results |
| 2804 | t1col = table1.cols.var1 |
| 2805 | t2col = table1.cols.var2 |
| 2806 | self.assertIsNotNone(t2col) |
| 2807 | condition = "(il<=t1col)&(t1col<=sl)&(t2col==True)" |
| 2808 | self.assertTrue( |
| 2809 | table1.will_query_use_indexing(condition) |
| 2810 | == fzset([t1col.pathname]) |
| 2811 | ) |
| 2812 | results1 = [ |
| 2813 | p["var1"] |
| 2814 | for p in table1.where(condition, start=0, stop=10, step=1) |
| 2815 | ] |
| 2816 | results2 = [ |
| 2817 | p["var1"] |
| 2818 | for p in table2.iterrows(0, 10, 1) |
| 2819 | if il <= p["var1"] <= sl and p["var2"] is True |
| 2820 | ] |
| 2821 | # sort lists (indexing does not guarantee that rows are returned in |
| 2822 | # order) |
| 2823 | results1.sort() |
| 2824 | results2.sort() |
| 2825 | if common.verbose: |
| 2826 | print("Limits:", il, sl) |
| 2827 | print("Length results:", len(results1)) |
| 2828 | print("Should be:", len(results2)) |
| 2829 | self.assertEqual(len(results1), len(results2)) |
| 2830 | self.assertEqual(results1, results2) |
| 2831 | |
| 2832 | # Repeat the selection with a simpler condition |
| 2833 | condition = "(il<=t1col)&(t1col<=sl)" |
| 2834 | self.assertTrue( |
| 2835 | table1.will_query_use_indexing(condition) |
| 2836 | == fzset([t1col.pathname]) |
| 2837 | ) |
| 2838 | results1 = [ |
| 2839 | p["var1"] |
| 2840 | for p in table1.where(condition, start=0, stop=10, step=1) |
| 2841 | ] |
| 2842 | results2 = [ |
nothing calls this directly
no test coverage detected