#NEWLINE# def _pprint( params , offset = 0 , printer = repr ) : #NEWLINE# #INDENT# "Pretty print the dictionary 'params'\n\n    Parameters\n    ----------\n    params: dict\n        The dictionary to pretty print\n\n    offset: int\n        The offset in characters to add at the begin of each line.\n\n    printer:\n        The function to convert entries to strings, typically\n        the builtin str or repr\n\n    " #NEWLINE# options = np . get_printoptions ( ) #NEWLINE# np . set_printoptions ( precision = 5 , threshold = 64 , edgeitems = 2 ) #NEWLINE# params_list = list ( ) #NEWLINE# this_line_length = offset #NEWLINE# line_sep = ( ',\n' + ( ( 1 + ( offset // 2 ) ) * ' ' ) ) #NEWLINE# for ( i , ( k , v ) ) in enumerate ( sorted ( six . iteritems ( params ) ) ) : #NEWLINE# #INDENT# if ( type ( v ) is float ) : #NEWLINE# #INDENT# this_repr = ( '%s=%s' % ( k , str ( v ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# this_repr = ( '%s=%s' % ( k , printer ( v ) ) ) #NEWLINE# #UNINDENT# if ( len ( this_repr ) > 500 ) : #NEWLINE# #INDENT# this_repr = ( ( this_repr [ : 300 ] + '...' ) + this_repr [ ( - 100 ) : ] ) #NEWLINE# #UNINDENT# if ( i > 0 ) : #NEWLINE# #INDENT# if ( ( ( this_line_length + len ( this_repr ) ) >= 75 ) or ( '\n' in this_repr ) ) : #NEWLINE# #INDENT# params_list . append ( line_sep ) #NEWLINE# this_line_length = len ( options ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# params_list . append ( ', ' ) #NEWLINE# this_line_length += 2 #NEWLINE# #UNINDENT# #UNINDENT# params_list . append ( this_repr ) #NEWLINE# this_line_length += len ( this_repr ) #NEWLINE# #UNINDENT# np . set_printoptions ( ** options ) #NEWLINE# lines = '' . join ( params_list ) #NEWLINE# lines = '\n' . join ( ( l . rstrip ( ' ' ) for l in lines . split ( '\n' ) ) ) #NEWLINE# return lines