Permutation
dstz.element.permutation
order_code_intersection(a, b)
Finds the ordered intersection of two tuples.
This function identifies elements that are common to both input tuples,
a and b. It returns a list of tuples, where each inner tuple
represents a valid sequence of indices corresponding to the common
elements. The indices are determined by taking the maximum index for each
common element from both tuples, and the final result is sorted based on
these indices to maintain a combined ordering from both input sequences.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
tuple
|
The first ordered tuple. |
required |
b
|
tuple
|
The second ordered tuple. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
A list of tuples, where each inner tuple contains the indices
of an intersecting element from |
Source code in dstz/element/permutation.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
permutation_set(simple_space, allow_empty=False)
Generates all permutations of all subsets from a given space.
This function first finds all subsets of simple_space (similar to a
powerset) and then generates all possible orderings (permutations) for
each of these subsets. Each unique permutation is wrapped in an Element
object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simple_space
|
set
|
The input set from which to generate permutations. |
required |
allow_empty
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
set |
A set of |
Example
s = {Element('A'), Element('B')} permutation_set(s) {Element(('A',)), Element(('B',)), Element(('A', 'B')), Element(('B', 'A'))}
Source code in dstz/element/permutation.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |