#NEWLINE# def check_h5_settings( f , n , dim , min_dist = None , names = None , cats = None , write = False ) : #NEWLINE# #INDENT# '\n    Checks that the hdf5 div cache file has settings that agree with the\n    passed settings. If write, adds them to the file if not present.\n    ' #NEWLINE# if any ( ( ( divs . shape != ( n , n ) ) for ( name , div_group ) in f . items ( ) if ( name != '_meta' ) for divs in div_group . values ( ) ) ) : #NEWLINE# #INDENT# raise ValueError ( 'existing divs have wrong shape' ) #NEWLINE# #UNINDENT# if ( '_meta' in f ) : #NEWLINE# #INDENT# meta_group = f [ '_meta' ] #NEWLINE# def check( name , value ) : #NEWLINE# #INDENT# if np . any ( ( meta_group [ name ] [ ( ) ] != value ) ) : #NEWLINE# #INDENT# raise ValueError ( "attribute '{}' differs in file" . format ( name ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if write : #NEWLINE# #INDENT# meta_group = f . require_group ( '_meta' ) #NEWLINE# def check( name , value ) : #NEWLINE# #INDENT# meta_group [ name ] = value #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# meta_group = None #NEWLINE# def check( name , value ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# check ( 'dim' , dim ) #NEWLINE# check ( 'min_dist' , ( default_min_dist ( dim ) if ( min_dist is None ) else min_dist ) ) #NEWLINE# for x in [ 'names' , 'cats' ] : #NEWLINE# #INDENT# if ( ( meta_group is not None ) and ( x in meta_group ) ) : #NEWLINE# #INDENT# if ( meta_group [ x ] . shape != ( n , ) ) : #NEWLINE# #INDENT# raise ValueError ( "'{}'' has wrong shape in file" . format ( x ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( ( names is not None ) or ( cats is not None ) ) : #NEWLINE# #INDENT# reconcile_file_order ( f , names = names , cats = cats , write = write )