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

Method _get_condition_key

tables/table.py:1354–1393  ·  view source on GitHub ↗

Get the condition cache key for `condition` with `condvars`. Currently, the key is a tuple of `condition`, column variables names, normal variables names, column paths and variable paths (all are tuples).

(
        self,
        condition: str,
        condvars: dict[str, Column],
    )

Source from the content-addressed store, hash-verified

1352 return reqvars
1353
1354 def _get_condition_key(
1355 self,
1356 condition: str,
1357 condvars: dict[str, Column],
1358 ) -> tuple[
1359 str,
1360 tuple[str, ...],
1361 tuple[str, ...],
1362 tuple[str, ...],
1363 tuple[Any, ...],
1364 ]:
1365 """Get the condition cache key for `condition` with `condvars`.
1366
1367 Currently, the key is a tuple of `condition`, column variables
1368 names, normal variables names, column paths and variable paths
1369 (all are tuples).
1370
1371 """
1372 # Variable names for column and normal variables.
1373 colnames, varnames = [], []
1374 # Column paths and types for each of the previous variable.
1375 colpaths, vartypes = [], []
1376 for var, val in condvars.items():
1377 if hasattr(val, "pathname"): # column
1378 colnames.append(var)
1379 colpaths.append(val.pathname)
1380 else: # array
1381 try:
1382 varnames.append(var)
1383 vartypes.append(ne.necompiler.getType(val)) # expensive
1384 except ValueError:
1385 # This is more clear than the error given by Numexpr.
1386 raise TypeError(
1387 "variable ``%s`` has data type ``%s``, "
1388 "not allowed in conditions" % (var, val.dtype.name)
1389 )
1390 colnames, varnames = tuple(colnames), tuple(varnames)
1391 colpaths, vartypes = tuple(colpaths), tuple(vartypes)
1392 condkey = (condition, colnames, varnames, colpaths, vartypes)
1393 return condkey
1394
1395 def _compile_condition(
1396 self,

Callers 1

_compile_conditionMethod · 0.95

Calls 2

itemsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected