#NEWLINE# def _insert_many( self , i , j , x ) : #NEWLINE# #INDENT# 'Inserts new nonzero at each (i, j) with value x\n\n        Here (i,j) index major and minor respectively.\n        i, j and x must be non-empty, 1d arrays.\n        Inserts each major group (e.g. all entries per row) at a time.\n        Maintains has_sorted_indices property.\n        Modifies i, j, x in place.\n        ' #NEWLINE# order = np . argsort ( i , kind = 'mergesort' ) #NEWLINE# i = i . take ( order , mode = 'clip' ) #NEWLINE# j = j . take ( order , mode = 'clip' ) #NEWLINE# x = x . take ( order , mode = 'clip' ) #NEWLINE# do_sort = self . has_sorted_indices #NEWLINE# idx_dtype = get_index_dtype ( ( self . indices , self . indptr ) , maxval = ( self . indptr [ ( - 1 ) ] + x . size ) ) #NEWLINE# self . indptr = np . asarray ( self . indptr , dtype = idx_dtype ) #NEWLINE# self . indices = np . asarray ( self . indices , dtype = idx_dtype ) #NEWLINE# i = np . asarray ( i , dtype = idx_dtype ) #NEWLINE# j = np . asarray ( j , dtype = idx_dtype ) #NEWLINE# indices_parts = [ ] #NEWLINE# data_parts = [ ] #NEWLINE# ( ui , ui_indptr ) = np . unique ( i , return_index = True ) #NEWLINE# ui_indptr = np . append ( ui_indptr , len ( j ) ) #NEWLINE# new_nnzs = np . diff ( ui_indptr ) #NEWLINE# prev = 0 #NEWLINE# for ( c , ( ii , js , je ) ) in enumerate ( izip ( ui , ui_indptr , ui_indptr [ 1 : ] ) ) : #NEWLINE# #INDENT# start = self . indptr [ prev ] #NEWLINE# stop = self . indptr [ ii ] #NEWLINE# indices_parts . append ( self . indices [ start : stop ] ) #NEWLINE# data_parts . append ( self . data [ start : stop ] ) #NEWLINE# ( uj , uj_indptr ) = np . unique ( j [ js : je ] [ : : ( - 1 ) ] , return_index = True ) #NEWLINE# if ( len ( uj ) == ( je - js ) ) : #NEWLINE# #INDENT# indices_parts . append ( j [ js : je ] ) #NEWLINE# data_parts . append ( x [ js : je ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# indices_parts . append ( j [ js : je ] [ : : ( - 1 ) ] [ uj_indptr ] ) #NEWLINE# data_parts . append ( x [ js : je ] [ : : ( - 1 ) ] [ uj_indptr ] ) #NEWLINE# new_nnzs [ c ] = len ( uj ) #NEWLINE# #UNINDENT# prev = ii #NEWLINE# #UNINDENT# start = self . indptr [ ii ] #NEWLINE# indices_parts . append ( self . indices [ start : ] ) #NEWLINE# data_parts . append ( self . data [ start : ] ) #NEWLINE# self . indices = np . concatenate ( indices_parts ) #NEWLINE# self . data = np . concatenate ( data_parts ) #NEWLINE# nnzs = np . asarray ( np . ediff1d ( self . indptr , to_begin = 0 ) , dtype = idx_dtype ) #NEWLINE# nnzs [ 1 : ] [ ui ] += new_nnzs #NEWLINE# self . indptr = np . cumsum ( nnzs , out = nnzs ) #NEWLINE# if do_sort : #NEWLINE# #INDENT# self . has_sorted_indices = False #NEWLINE# self . sort_indices ( ) #NEWLINE# #UNINDENT# self . check_format ( full_check = False )