#NEWLINE# def _add_item( self , dim_vals , data , sort = True , update = True ) : #NEWLINE# #INDENT# '\n        Adds item to the data, applying dimension types and ensuring\n        key conforms to Dimension type and values.\n        ' #NEWLINE# if ( not isinstance ( dim_vals , tuple ) ) : #NEWLINE# #INDENT# dim_vals = ( dim_vals , ) #NEWLINE# #UNINDENT# self . _item_check ( dim_vals , data ) #NEWLINE# dim_types = zip ( self . _cached_index_types , dim_vals ) #NEWLINE# dim_vals = tuple ( ( ( v if ( None in [ t , v ] ) else t ( v ) ) for ( t , v ) in dim_types ) ) #NEWLINE# if self . _cached_categorical : #NEWLINE# #INDENT# valid_vals = zip ( self . kdims , dim_vals ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# valid_vals = [ ] #NEWLINE# #UNINDENT# for ( dim , val ) in valid_vals : #NEWLINE# #INDENT# vals = self . _cached_index_values [ dim . name ] #NEWLINE# if ( vals == 'initial' ) : #NEWLINE# #INDENT# self . _cached_index_values [ dim . name ] = [ ] #NEWLINE# #UNINDENT# if ( ( not self . _instantiated ) and ( self . get_dimension ( dim ) . values == 'initial' ) ) : #NEWLINE# #INDENT# if ( val not in vals ) : #NEWLINE# #INDENT# self . _cached_index_values [ dim . name ] . append ( val ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( vals and ( val not in vals ) ) : #NEWLINE# #INDENT# raise KeyError ( ( '%s dimension value %s not in specified dimension values.' % ( dim , repr ( val ) ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( update and ( dim_vals in self . data ) and isinstance ( self . data [ dim_vals ] , ( MultiDimensionalMapping , OrderedDict ) ) ) : #NEWLINE# #INDENT# self . data [ dim_vals ] . update ( data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . data [ dim_vals ] = data #NEWLINE# #UNINDENT# if sort : #NEWLINE# #INDENT# self . _resort ( )