1111 | | [[1, 2], [2, 3], [2, 1], [3, 1], [1, 3], [3, 2]] |
| 1119 | ((1, 2), (2, 3), (2, 1), (3, 1), (1, 3), (3, 2)) |
1125 | | [[['a', 'c'], ['b', 'd']], [['a', 'd'], ['b', 'c']], |
1126 | | [['b', 'c'], ['a', 'd']], [['b', 'd'], ['a', 'c']], |
1127 | | [['c', 'd'], ['a', 'b']], [['a', 'b'], ['c', 'd']]] |
| 1131 | (({'a', 'c'}, {'b', 'd'}), |
| 1132 | ({'a', 'd'}, {'c', 'b'}), |
| 1133 | ({'c', 'b'}, {'a', 'd'}), |
| 1134 | ({'b', 'd'}, {'a', 'c'}), |
| 1135 | ({'c', 'd'}, {'a', 'b'}), |
| 1136 | ({'a', 'b'}, {'c', 'd'})) |
1131 | | sage: S4 = PermutationGroup([ [((11,(12,13)),'d')], [((12,(12,11)),(11,(12,13)))], [((12,(12,11)),'b')] ]) |
| 1140 | sage: S4 = PermutationGroup([ [((11,(12,13)),'d')], |
| 1141 | ... [((12,(12,11)),(11,(12,13)))], [((12,(12,11)),'b')] ]) |
1133 | | [[[(11, (12, 13)), (12, (12, 11))], ['b', 'd']], |
1134 | | [['d', (12, (12, 11))], ['b', (11, (12, 13))]], |
1135 | | [['b', (11, (12, 13))], ['d', (12, (12, 11))]], |
1136 | | [['d', (11, (12, 13))], ['b', (12, (12, 11))]], |
1137 | | [['b', 'd'], [(11, (12, 13)), (12, (12, 11))]], |
1138 | | [['b', (12, (12, 11))], ['d', (11, (12, 13))]]] |
1139 | | |
| 1143 | (({(11, (12, 13)), (12, (12, 11))}, {'b', 'd'}), |
| 1144 | ({'d', (12, (12, 11))}, {(11, (12, 13)), 'b'}), |
| 1145 | ({(11, (12, 13)), 'b'}, {'d', (12, (12, 11))}), |
| 1146 | ({(11, (12, 13)), 'd'}, {'b', (12, (12, 11))}), |
| 1147 | ({'b', 'd'}, {(11, (12, 13)), (12, (12, 11))}), |
| 1148 | ({'b', (12, (12, 11))}, {(11, (12, 13)), 'd'})) |
1141 | | def input_to_gap(x, depth, sort): |
1142 | | if depth: |
1143 | | ans = [input_to_gap(xx,depth-1,sort) for xx in x] |
1144 | | if depth == 1 and sort: |
1145 | | ans.sort() |
1146 | | return ans |
| 1150 | from sage.sets.set import Set |
| 1151 | actions = { |
| 1152 | "OnPoints" : [], |
| 1153 | "OnSets" : [Set], |
| 1154 | "OnTuples" : [tuple], |
| 1155 | "OnSetsSets" : [Set, Set], |
| 1156 | "OnSetsDisjointSets" : [Set, Set], |
| 1157 | "OnSetsTuples" : [Set, tuple], |
| 1158 | "OnTuplesSets" : [tuple, Set], |
| 1159 | "OnTuplesTuples" : [tuple, tuple], |
| 1160 | } |
| 1161 | |
| 1162 | def input_for_gap(x, depth, container): |
| 1163 | if depth == len(container): |
| 1164 | try: |
| 1165 | return self._domain_to_gap[x] |
| 1166 | except KeyError: |
| 1167 | raise ValueError('{0} is not part of the domain'.format(x)) |
| 1168 | x = [input_for_gap(xx, depth+1, container) for xx in x] |
| 1169 | if container[depth] is Set: |
| 1170 | x.sort() |
| 1171 | return x |
| 1172 | |
| 1173 | def gap_to_output(x, depth, container): |
| 1174 | if depth == len(container): |
| 1175 | return self._domain_from_gap[x] |
1148 | | return self._domain_to_gap[x] |
1149 | | |
1150 | | def gap_to_output(x, depth): |
1151 | | if depth: |
1152 | | return [gap_to_output(xx,depth-1) for xx in x] |
1153 | | else: |
1154 | | return self._domain_from_gap[x] |
1155 | | |
1156 | | sort = False |
1157 | | |
1158 | | actions = { |
1159 | | "OnPoints" : {"depth" : 0, "sort" : False}, |
1160 | | "OnSets" : {"depth" : 1, "sort" : True}, |
1161 | | "OnTuples" : {"depth" : 1, "sort" : False}, |
1162 | | "OnTuples" : {"depth" : 1, "sort" : False}, |
1163 | | "OnSetsSets" : {"depth" : 2, "sort" : True}, |
1164 | | "OnSetsDisjointSets" : {"depth" : 2, "sort" : True}, |
1165 | | "OnTuplesSets" : {"depth" : 2, "sort" : True}, |
1166 | | "OnTuplesTuples" : {"depth" : 2, "sort" : False}, |
1167 | | "OnTuplesTuples" : {"depth" : 2, "sort" : False} |
1168 | | } |
| 1177 | x = [gap_to_output(xx, depth+1, container) for xx in x] |
| 1178 | return container[depth](x) |
1172 | | raise ValueError("This action is not implemented (yet?).") |
1173 | | |
1174 | | try: |
1175 | | point = input_to_gap(point, **params) |
1176 | | except KeyError: |
1177 | | raise ValueError("One element does not seem to be part of the domain.") |
1178 | | |
1179 | | ans = self._gap_().Orbit(point, action).sage() |
1180 | | |
1181 | | return gap_to_output(ans, params['depth']+1) |
| 1182 | raise NotImplementedError("This action is not implemented (yet?).") |
| 1183 | point = input_for_gap(point, 0, container) |
| 1184 | result = self._gap_().Orbit(point, action).sage() |
| 1185 | result = [gap_to_output(x, 0, container) for x in result] |
| 1186 | return tuple(result) |