#NEWLINE# def gen_M_c_from_T( T , cctypes = None , colnames = None ) : #NEWLINE# #INDENT# num_rows = len ( T ) #NEWLINE# num_cols = len ( T [ 0 ] ) #NEWLINE# if ( cctypes is None ) : #NEWLINE# #INDENT# cctypes = ( [ 'continuous' ] * num_cols ) #NEWLINE# #UNINDENT# if ( colnames is None ) : #NEWLINE# #INDENT# colnames = list ( range ( num_cols ) ) #NEWLINE# #UNINDENT# T_array_transpose = numpy . array ( T ) . T #NEWLINE# column_metadata = [ ] #NEWLINE# for ( cctype , column_data ) in zip ( cctypes , T_array_transpose ) : #NEWLINE# #INDENT# metadata_generator = metadata_generator_lookup [ cctype ] #NEWLINE# metadata = metadata_generator ( column_data ) #NEWLINE# column_metadata . append ( metadata ) #NEWLINE# #UNINDENT# name_to_idx = dict ( zip ( colnames , range ( num_cols ) ) ) #NEWLINE# idx_to_name = dict ( zip ( map ( str , range ( num_cols ) ) , colnames ) ) #NEWLINE# M_c = dict ( name_to_idx = name_to_idx , idx_to_name = idx_to_name , column_metadata = column_metadata ) #NEWLINE# return M_c