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

Method test09a

tables/tests/test_indexvalues.py:1393–1503  ·  view source on GitHub ↗

Checking non-indexed where() (string flavor)

(self)

Source from the content-addressed store, hash-verified

1391 self.assertEqual(results1, results2)
1392
1393 def test09a(self):
1394 """Checking non-indexed where() (string flavor)"""
1395
1396 if common.verbose:
1397 print("\n", "-=" * 30)
1398 print("Running %s.test09a..." % self.__class__.__name__)
1399
1400 table1 = self.h5file.root.table1
1401 table2 = self.h5file.root.table2
1402
1403 table1._disable_indexing_in_queries()
1404
1405 # Convert the limits to the appropriate type
1406 il = str(self.il).encode("ascii")
1407 sl = str(self.sl).encode("ascii")
1408
1409 # Do some selections and check the results
1410 t1col = table1.cols.var1
1411 self.assertIsNotNone(t1col)
1412
1413 # First selection
1414 condition = "t1col<=sl"
1415 self.assertTrue(not table1.will_query_use_indexing(condition))
1416 results1 = [
1417 p["var1"] for p in table1.where(condition, start=2, stop=10)
1418 ]
1419 results2 = [
1420 p["var1"] for p in table2.iterrows(2, 10) if p["var1"] <= sl
1421 ]
1422 if common.verbose:
1423 print("Limit:", sl)
1424 print("Length results:", len(results1))
1425 print("Should be:", len(results2))
1426 self.assertEqual(len(results1), len(results2))
1427 self.assertEqual(results1, results2)
1428
1429 # Second selection
1430 condition = "(il<t1col)&(t1col<sl)"
1431 self.assertTrue(not table1.will_query_use_indexing(condition))
1432 results1 = [
1433 p["var1"]
1434 for p in table1.where(condition, start=2, stop=30, step=2)
1435 ]
1436 results2 = [
1437 p["var1"] for p in table2.iterrows(2, 30, 2) if il < p["var1"] < sl
1438 ]
1439 if common.verbose:
1440 print("Limits:", il, sl)
1441 print("Length results:", len(results1))
1442 print("Should be:", len(results2))
1443 self.assertEqual(len(results1), len(results2))
1444 self.assertEqual(results1, results2)
1445
1446 # Third selection
1447 condition = "(il>t1col)&(t1col>sl)"
1448 self.assertTrue(not table1.will_query_use_indexing(condition))
1449 results1 = [
1450 p["var1"] for p in table1.where(condition, start=2, stop=-5)

Callers

nothing calls this directly

Calls 5

whereMethod · 0.80
iterrowsMethod · 0.45

Tested by

no test coverage detected