utils

Utilities for use under the hood.

utils.assertions module

Utilities for asserting inputs and states.

tt.utils.assertions.assert_all_valid_keys(symbol_input_dict, symbol_set)

Assert that all keys in the passed input dict are valid.

Valid keys are considered those that are present in the passed set of symbols and that map to valid Boolean values. Dictionaries cannot have duplicate keys, so no duplicate checking is necessary.

Parameters:
  • symbol_input_dict (Dict) – A dict containing symbol names mapping to what should be Boolean values.
  • symbol_set (Set[str]) – A set of the symbol names expected to
Raises:
  • ExtraSymbolError – If any keys in the passed input dict are not present in the passed set of symbols.
  • InvalidBooleanValueError – If any values in the passed input dict are not valid Boolean values (1, 0, True, or False).
tt.utils.assertions.assert_iterable_contains_all_expr_symbols(iterable, reference_set)

Assert a one-to-one presence of all symbols in the passed iterable.

Parameters:
  • iterable – An iterable of strings to assert.
  • reference_set (Set[str]) – A set of strings, each of which will be asserted to be present in the passed iterable.

Note

This function will consume the passed iterable.

Raises:
  • DuplicateSymbolError – If the passed iterable contains more than one of the same symbol.
  • ExtraSymbolError – If the passed iterable contains symbols not present in the reference set.
  • MissingSymbolError – If the passed iterable is missing symbols present in the reference set.