@@ -46,15 +46,14 @@ def __call__(cls, *args, **kwargs):
4646 from .comb_space import CombSpace
4747 arguments_profile = python_toolbox .arguments_profiling . \
4848 ArgumentsProfile (PermSpace .__init__ , None , * args , ** kwargs )
49- # if arguments_profile.get('fixed_map', None):
50- # raise UnallowedVariationSelectionException(
51- # {variations.Variation.FIXED: True,
52- # variations.Variation.COMBINATION: True,}
53- # )
49+ if arguments_profile .get ('fixed_map' , None ):
50+ raise UnallowedVariationSelectionException (
51+ {variations .Variation .FIXED : True ,
52+ variations .Variation .COMBINATION : True ,}
53+ )
5454 return super (PermSpaceType , CombSpace ).__call__ (
5555 iterable_or_length = arguments_profile ['iterable_or_length' ],
5656 n_elements = arguments_profile ['n_elements' ],
57- fixed_map = arguments_profile ['fixed_map' ],
5857 slice_ = arguments_profile ['slice_' ],
5958 _domain_for_checking = arguments_profile ['domain' ],
6059 _degrees_for_checking = arguments_profile ['degrees' ],
@@ -582,12 +581,37 @@ def __getitem__(self, i):
582581 (value in reserved_values and available_values .count (value )
583582 == reserved_values .count (value )))):
584583 wip_perm_sequence_dict [j ] = unused_value
584+
585+ ###########################################################
586+ # #
587+ # Tricky thing here: Trying to put as much as we can in a
588+ # sequence head that'll shorten the sequence we'll give to
589+ # the candidate space instead of using a fixed map, if
590+ # possible. This is crucial for `CombSpace` which can't use
591+ # `fixed_map`.
592+ head = []
593+ fixed_map_to_use = dict (wip_perm_sequence_dict )
594+ n_elements_to_use = self .n_elements
595+ for i in sequence_tools .CuteRange (infinity ):
596+ try :
597+ head .append (wip_perm_sequence_dict [i ])
598+ except KeyError :
599+ break
600+ else :
601+ del wip_perm_sequence_dict [i ]
602+ n_elements_to_use -= 1
603+ sequence_to_use = list (self .sequence )
604+ for item in head :
605+ sequence_to_use .remove (item )
606+
585607 candidate_sub_perm_space = PermSpace (
586- self . sequence ,
587- n_elements = self . n_elements ,
588- fixed_map = wip_perm_sequence_dict ,
608+ sequence_to_use ,
609+ n_elements = n_elements_to_use ,
610+ fixed_map = fixed_map_to_use ,
589611 is_combination = self .is_combination
590612 )
613+ # #
614+ ###########################################################
591615
592616 if wip_i < candidate_sub_perm_space .length :
593617 available_values .remove (unused_value )
0 commit comments