#NEWLINE# def check_format( self , full_check = True ) : #NEWLINE# #INDENT# 'check whether the matrix format is valid\n\n        Parameters\n        ----------\n        full_check : bool, optional\n            If `True`, rigorous check, O(N) operations. Otherwise\n            basic check, O(1) operations (default True).\n        ' #NEWLINE# ( major_name , minor_name ) = self . _swap ( ( 'row' , 'column' ) ) #NEWLINE# ( major_dim , minor_dim ) = self . _swap ( self . shape ) #NEWLINE# if ( self . indptr . dtype . kind != 'i' ) : #NEWLINE# #INDENT# warn ( ( 'indptr array has non-integer dtype (%s)' % self . indptr . dtype . name ) ) #NEWLINE# #UNINDENT# if ( self . indices . dtype . kind != 'i' ) : #NEWLINE# #INDENT# warn ( ( 'indices array has non-integer dtype (%s)' % self . indices . dtype . name ) ) #NEWLINE# #UNINDENT# idx_dtype = get_index_dtype ( ( self . indptr , self . indices ) ) #NEWLINE# self . indptr = np . asarray ( self . indptr , dtype = idx_dtype ) #NEWLINE# self . indices = np . asarray ( self . indices , dtype = major_name ) #NEWLINE# self . data = to_native ( self . data ) #NEWLINE# if ( ( self . data . ndim != 1 ) or ( self . indices . ndim != 1 ) or ( self . indptr . ndim != 1 ) ) : #NEWLINE# #INDENT# raise ValueError ( 'data, indices, and indptr should be 1-D' ) #NEWLINE# #UNINDENT# if ( len ( self . indptr ) != ( major_dim + 1 ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'index pointer size (%d) should be (%d)' % ( len ( self . indptr ) , ( major_dim + 1 ) ) ) ) #NEWLINE# #UNINDENT# if ( self . indptr [ 0 ] != 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'index pointer should start with 0' ) #NEWLINE# #UNINDENT# if ( len ( self . indices ) != len ( self . data ) ) : #NEWLINE# #INDENT# raise ValueError ( 'indices and data should have the same size' ) #NEWLINE# #UNINDENT# if ( self . indptr [ ( - 1 ) ] > len ( self . indices ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Last value of index pointer should be less than the size of index and data arrays' ) #NEWLINE# #UNINDENT# self . prune ( ) #NEWLINE# if full_check : #NEWLINE# #INDENT# if ( self . nnz > 0 ) : #NEWLINE# #INDENT# if ( self . indices . max ( ) >= minor_dim ) : #NEWLINE# #INDENT# raise ValueError ( ( '%s index values must be < %d' % ( minor_name , minor_dim ) ) ) #NEWLINE# #UNINDENT# if ( self . indices . min ( ) < 0 ) : #NEWLINE# #INDENT# raise ValueError ( ( '%s index values must be >= 0' % minor_name ) ) #NEWLINE# #UNINDENT# if ( np . diff ( self . indptr ) . min ( ) < 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'index pointer values must form a non-decreasing sequence' )