qsrlib_utils.combinations_and_permutations module

qsrlib_utils.combinations_and_permutations.possible_pairs(s, mirrors=True)[source]

Return possible pairs from a set of values.

Assume s = [‘a’, ‘b’]. Then return examples for the following calls are:

  • possible_pairs(s) returns [(‘a’, ‘b’), (‘b’, ‘a’)]
  • possible_pairs(s, mirros=False) returns [(‘a’, ‘b’)]
Parameters:
  • s (set or list or tuple) – Names of the elements from which the pairs will be created.
  • mirrors (bool) – Include mirrors or not.
Returns:

List of pairs as tuples.

Return type:

list of tuples of str

qsrlib_utils.combinations_and_permutations.possible_pairs_between_two_lists(s1, s2, mirrors=True)[source]

Return possible pairs between the elements of two sets.

Assume s1 = [‘a’, ‘b’] and s2 = [‘c’, ‘d’]. Then return examples for the following calls are:

  • possible_pairs_between_two_lists(s1, s2) returns [(‘a’, ‘c’), (‘a’, ‘d’), (‘b’, ‘c’), (‘b’, ‘d’), (‘c’, ‘a’), (‘c’, ‘b’), (‘d’, ‘a’), (‘d’, ‘b’)].
  • possible_pairs_between_two_lists(s1, s2, mirrors=False) returns [(‘a’, ‘c’), (‘a’, ‘d’), (‘b’, ‘c’), (‘b’, ‘d’)].
Parameters:
  • s1 (set or list or tuple) – Names of the first elements.
  • s2 (set or list or tuple) – Names of the second elements.
  • mirrors (bool) – Include mirrors or not.
Returns:

List of pairs as tuples.

Return type:

list of tuples of str

qsrlib_utils.combinations_and_permutations.possible_triplets(s, mirrors=True)[source]

Return the possible triplets from the list s.