<s> from combi . _python_toolbox import caching <EOL> from combi . _python_toolbox import sequence_tools <EOL> class _VariationAddingMixin : <EOL> '''<STR_LIT>''' <EOL> def get_rapplied ( self , sequence ) : <EOL> '''<STR_LIT>''' <EOL> if self . is_rapplied : <EOL> raise TypeError ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> sequence = sequence_tools . ensure_iterable_is_immutable_sequence ( sequence ) <EOL> if len ( sequence ) != self . sequence_length : <EOL> raise Exception <EOL> return PermSpace ( <EOL> sequence , n_elements = self . n_elements , domain = self . domain , <EOL> fixed_map = { key : sequence [ value ] for key , value in <EOL> self . fixed_map . items ( ) } , <EOL> degrees = self . degrees , slice_ = self . canonical_slice , <EOL> is_combination = self . is_combination , <EOL> perm_type = self . perm_type <EOL> ) <EOL> def get_partialled ( self , n_elements ) : <EOL> '''<STR_LIT>''' <EOL> if self . is_sliced : <EOL> raise TypeError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) <EOL> return PermSpace ( <EOL> self . sequence , n_elements = n_elements , domain = self . domain , <EOL> fixed_map = self . fixed_map , degrees = self . degrees , slice_ = None , <EOL> is_combination = self . is_combination , <EOL> perm_type = self . perm_type <EOL> ) <EOL> @ caching . CachedProperty <EOL> def combinationed ( self ) : <EOL> '''<STR_LIT>''' <EOL> from . comb import Comb <EOL> if self . is_sliced : <EOL> raise TypeError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) <EOL> if self . is_typed : <EOL> raise TypeError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) <EOL> if self . is_degreed : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> return PermSpace ( <EOL> self . sequence , n_elements = self . n_elements , domain = self . domain , <EOL> fixed_map = self . fixed_map , is_combination = True , <EOL> perm_type = Comb <EOL> ) <EOL> def get_dapplied ( self , domain ) : <EOL> '''<STR_LIT>''' <EOL> from . import variations <EOL> if self . is_combination : <EOL> raise variations . UnallowedVariationSelectionException ( <EOL> { variations . Variation . DAPPLIED : True , <EOL> variations . Variation . COMBINATION : True , } <EOL> ) <EOL> domain = sequence_tools . ensure_iterable_is_immutable_sequence ( domain ) <EOL> if len ( domain ) != self . n_elements : <EOL> raise Exception <EOL> return PermSpace ( <EOL> self . sequence , n_elements = self . n_elements , domain = domain , <EOL> fixed_map = { domain [ key ] : value for key , value in <EOL> self . _undapplied_fixed_map } , <EOL> degrees = self . degrees , slice_ = self . canonical_slice , <EOL> is_combination = self . is_combination , <EOL> perm_type = self . perm_type <EOL> ) <EOL> def get_fixed ( self , fixed_map ) : <EOL> '''<STR_LIT>''' <EOL> if self . is_sliced : <EOL> raise TypeError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) <EOL> combined_fixed_map = dict ( self . fixed_map ) <EOL> for key , value in fixed_map . items ( ) : <EOL> if key in self . fixed_map : <EOL> assert self . fixed_map [ key ] == value <EOL> combined_fixed_map [ key ] = value <EOL> return PermSpace ( <EOL> self . sequence , n_elements = self . n_elements , domain = self . domain , <EOL> fixed_map = combined_fixed_map , degrees = self . degrees , slice_ = None , <EOL> is_combination = self . is_combination , perm_type = self . perm_type <EOL> ) <EOL> def get_degreed ( self , degrees ) : <EOL> '''<STR_LIT>''' <EOL> from . import variations <EOL> if self . is_sliced : <EOL> raise TypeError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) <EOL> if self . is_combination : <EOL> raise variations . UnallowedVariationSelectionException ( <EOL> { variations . Variation . DEGREED : True , <EOL> variations . Variation . COMBINATION : True , } <EOL> ) <EOL> degrees = sequence_tools . to_tuple ( degrees , item_type = int ) <EOL> if not degrees : <EOL> return self <EOL> degrees_to_use = degrees if not self . is_degreed else set ( degrees ) & set ( self . degrees ) <EOL> return PermSpace ( <EOL> self . sequence , n_elements = self . n_elements , domain = self . domain , <EOL> fixed_map = self . fixed_map , degrees = degrees_to_use , <EOL> is_combination = self . is_combination , perm_type = self . perm_type <EOL> ) <EOL> def get_typed ( self , perm_type ) : <EOL> '''<STR_LIT>''' <EOL> return PermSpace ( <EOL> self . sequence , n_elements = self . n_elements , domain = self . domain , <EOL> fixed_map = self . fixed_map , degrees = self . degrees , <EOL> slice_ = self . canonical_slice , is_combination = self . is_combination , <EOL> perm_type = perm_type <EOL> ) </s>
