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

Function _get_idx_expr

tables/conditions.py:332–363  ·  view source on GitHub ↗

Extract an indexable expression out of `exprnode`. Looks for variable-constant comparisons in the expression node `exprnode` involving variables in `indexedcols`. It returns a tuple of (idxexprs, strexpr) where 'idxexprs' is a list of expressions in the form ``(var, (ops), (limits)

(
    expr: ne.expressions.ExpressionNode,
    indexedcols: frozenset[str],
)

Source from the content-addressed store, hash-verified

330
331
332def _get_idx_expr(
333 expr: ne.expressions.ExpressionNode,
334 indexedcols: frozenset[str],
335) -> tuple[list[tuple[Any, tuple[str], tuple[Any]]], list[str]]:
336 """Extract an indexable expression out of `exprnode`.
337
338 Looks for variable-constant comparisons in the expression node
339 `exprnode` involving variables in `indexedcols`.
340
341 It returns a tuple of (idxexprs, strexpr) where 'idxexprs' is a
342 list of expressions in the form ``(var, (ops), (limits))`` and
343 'strexpr' is the indexable expression in string format.
344
345 Expressions such as ``0 < c1 <= 1`` do not work as expected.
346
347 Right now only some of the *indexable comparisons* are considered:
348
349 * ``a <[=] x``, ``a == x`` and ``a >[=] x``
350 * ``(a <[=] x) & (y <[=] b)`` and ``(a == x) | (b == y)``
351 * ``~(~c_bool)``, ``~~c_bool`` and ``~(~c_bool) & (c_extra != 2)``
352
353 (where ``a``, ``b`` and ``c_bool`` are indexed columns, but
354 ``c_extra`` is not)
355
356 Particularly, the ``!=`` operator and negations of complex boolean
357 expressions are *not considered* as valid candidates:
358
359 * ``a != 1`` and ``c_bool != False``
360 * ``~((a > 0) & (c_bool))``
361
362 """
363 return _get_idx_expr_recurse(expr, indexedcols, [], [""])
364
365
366class CompiledCondition:

Callers 1

compile_conditionFunction · 0.85

Calls 1

_get_idx_expr_recurseFunction · 0.85

Tested by

no test coverage detected