#NEWLINE# def getComp( self , k , doCollapseK1 = True ) : #NEWLINE# #INDENT# ' Returns ParamBag object for component "k" of self.\n    ' #NEWLINE# if ( ( k < 0 ) or ( k >= self . K ) ) : #NEWLINE# #INDENT# raise IndexError ( ( 'Bad compID. Expected [0, %d] but provided %d' % ( ( self . K - 1 ) , k ) ) ) #NEWLINE# #UNINDENT# cPB = ParamBag ( K = 1 , D = self . D , doCollapseK1 = doCollapseK1 ) #NEWLINE# for key in self . _FieldDims : #NEWLINE# #INDENT# arr = getattr ( self , key ) #NEWLINE# dims = self . _FieldDims [ key ] #NEWLINE# if ( dims is not None ) : #NEWLINE# #INDENT# if ( self . K == 1 ) : #NEWLINE# #INDENT# cPB . setField ( key , arr , dims = dims ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# singleArr = arr [ k ] #NEWLINE# if doCollapseK1 : #NEWLINE# #INDENT# cPB . setField ( key , singleArr , dims = dims ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( singleArr . ndim == 0 ) : #NEWLINE# #INDENT# cPB . setField ( key , singleArr [ np . newaxis ] , dims = dims ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cPB . setField ( key , singleArr [ np . newaxis , : ] , dims = dims ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# cPB . setField ( key , arr ) #NEWLINE# #UNINDENT# #UNINDENT# return cPB