#NEWLINE# def mergeComps( self , kA , kB ) : #NEWLINE# #INDENT# ' Merge components kA, kB into a single component\n    ' #NEWLINE# if ( self . K <= 1 ) : #NEWLINE# #INDENT# raise ValueError ( 'Must have at least 2 components to merge.' ) #NEWLINE# #UNINDENT# if ( kB == kA ) : #NEWLINE# #INDENT# raise ValueError ( 'Distinct component ids required.' ) #NEWLINE# #UNINDENT# for ( key , dims ) in self . _Fields . _FieldDims . items ( ) : #NEWLINE# #INDENT# if ( ( dims is not None ) and ( dims != ( ) ) ) : #NEWLINE# #INDENT# arr = getattr ( self . _Fields , key ) #NEWLINE# if ( self . hasMergeTerm ( key ) and ( dims == 'K' ) ) : #NEWLINE# #INDENT# arr [ kA ] = getattr ( self . _MergeTerms , key ) [ ( kA , kB ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# arr [ kA ] += arr [ self ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if self . hasELBOTerms ( ) : #NEWLINE# #INDENT# for ( key , dims ) in self . _ELBOTerms . _FieldDims . items ( ) : #NEWLINE# #INDENT# if ( self . hasMergeTerm ( key ) and ( dims == 'K' ) ) : #NEWLINE# #INDENT# arr = getattr ( self . _ELBOTerms , key ) #NEWLINE# mArr = getattr ( self . _MergeTerms , key ) #NEWLINE# arr [ kA ] = mArr [ ( kA , kB ) ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if self . hasMergeTerms ( ) : #NEWLINE# #INDENT# for ( key , dims ) in self . _MergeTerms . _FieldDims . items ( ) : #NEWLINE# #INDENT# if ( dims == ( 'K' , 'K' ) ) : #NEWLINE# #INDENT# mArr = getattr ( self . _MergeTerms , key ) #NEWLINE# mArr [ kA , ( kA + 1 ) : ] = np . nan #NEWLINE# mArr [ : kA , kA ] = np . nan #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . _Fields . removeComp ( kB ) #NEWLINE# if self . hasELBOTerms ( ) : #NEWLINE# #INDENT# self . _ELBOTerms . removeComp ( kB ) #NEWLINE# #UNINDENT# if self . hasMergeTerms ( ) : #NEWLINE# #INDENT# self . _MergeTerms . removeComp ( kB )