MCPcopy Index your code
hub / github.com/PyTables/PyTables / _where

Method _where

tables/table.py:1577–1621  ·  view source on GitHub ↗

Low-level counterpart of `self.where()`.

(
        self,
        condition: str,
        condvars: dict[str, Column | np.ndarray] | None,
        start: str | None = None,
        stop: str | None = None,
        step: str | None = None,
    )

Source from the content-addressed store, hash-verified

1575 return self._where(condition, condvars, start, stop, step)
1576
1577 def _where(
1578 self,
1579 condition: str,
1580 condvars: dict[str, Column | np.ndarray] | None,
1581 start: str | None = None,
1582 stop: str | None = None,
1583 step: str | None = None,
1584 ) -> Iterator[tableextension.Row]:
1585 """Low-level counterpart of `self.where()`."""
1586 if profile:
1587 tref = clock()
1588 if profile:
1589 show_stats("Entering table._where", tref)
1590 # Adjust the slice to be used.
1591 start, stop, step = self._process_range_read(start, stop, step)
1592 if start >= stop: # empty range, reset conditions
1593 self._use_index = False
1594 self._where_condition = None
1595 return iter([])
1596
1597 # Compile the condition and extract usable index conditions.
1598 condvars = self._required_expr_vars(condition, condvars, depth=3)
1599 compiled = self._compile_condition(condition, condvars)
1600
1601 # Can we use indexes?
1602 if compiled.index_expressions:
1603 chunkmap = _table__where_indexed(
1604 self, compiled, condition, condvars, start, stop, step
1605 )
1606 if not isinstance(chunkmap, np.ndarray):
1607 # If it is not a NumPy array it should be an iterator
1608 # Reset conditions
1609 self._use_index = False
1610 self._where_condition = None
1611 # ...and return the iterator
1612 return chunkmap
1613 else:
1614 chunkmap = None # default to an in-kernel query
1615
1616 args = [condvars[param] for param in compiled.parameters]
1617 self._where_condition = (compiled.function, args, compiled.kwargs)
1618 row = tableextension.Row(self)
1619 if profile:
1620 show_stats("Exiting table._where", tref)
1621 return row._iter(start, stop, step, chunkmap=chunkmap)
1622
1623 def read_where(
1624 self,

Callers 4

whereMethod · 0.95
read_whereMethod · 0.95
append_whereMethod · 0.95
get_where_listMethod · 0.95

Calls 5

_required_expr_varsMethod · 0.95
_compile_conditionMethod · 0.95
_table__where_indexedFunction · 0.85
_process_range_readMethod · 0.80
show_statsFunction · 0.70

Tested by

no test coverage detected