#NEWLINE# def append( self , matrix , axis ) : #NEWLINE# #INDENT# '\n        Appends a Matrix instance either row-wise (0) or column-wise (1).\n        When appended e.g. row-wise, the matrices must share the same column word index, and\n        the combined row word index cannot contain duplicates.\n\n        :param matrix: Matrix to be appended.\n        :param axis: 0 if appending row-wise, 1 if column-wise.\n        :return: A combined matrix.\n        ' #NEWLINE# axis_to_be_synced = int ( ( not axis ) ) #NEWLINE# mat = matrix . synchronize_word_order ( self , axis_to_be_synced ) #NEWLINE# if ( axis == 0 ) : #NEWLINE# #INDENT# if ( len ( set . intersection ( set ( matrix . row2word ) , set ( matrix . row2word ) ) ) != 0 ) : #NEWLINE# #INDENT# raise ValueError ( "The row to append doesn't only contain unique values." ) #NEWLINE# #UNINDENT# return self . _new_instance ( sp . vstack ( [ self . matrix , matrix . matrix ] , format = 'csr' ) , row2word = ( self . row2word + matrix . row2word ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( axis == 1 ) : #NEWLINE# #INDENT# if ( len ( set . intersection ( set ( self . col2word ) , set ( matrix . col2word ) ) ) != 0 ) : #NEWLINE# #INDENT# raise ValueError ( "The column to append doesn't only contain unique values." ) #NEWLINE# #UNINDENT# return self . _new_instance ( sp . hstack ( [ self . matrix , mat . matrix ] , format = 'csr' ) , col2word = ( self . col2word + matrix . col2word ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'Axis must be 0 or 1.' )