#NEWLINE# def map_to_T_with_M_c( T_uncast_array , M_c ) : #NEWLINE# #INDENT# T_uncast_array = numpy . array ( T_uncast_array ) #NEWLINE# for col_idx in range ( T_uncast_array . shape [ 1 ] ) : #NEWLINE# #INDENT# modeltype = M_c [ 'column_metadata' ] [ col_idx ] [ 'modeltype' ] #NEWLINE# if ( modeltype != 'symmetric_dirichlet_discrete' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# mapping = copy . copy ( M_c [ 'column_metadata' ] [ col_idx ] [ 'code_to_value' ] ) #NEWLINE# mapping [ 'NAN' ] = numpy . nan #NEWLINE# col_data = T_uncast_array [ : , col_idx ] #NEWLINE# to_upper = ( lambda el : el . upper ( ) ) #NEWLINE# is_nan_str = ( numpy . array ( map ( to_upper , col_data ) ) == 'NAN' ) #NEWLINE# col_data [ is_nan_str ] = 'NAN' #NEWLINE# mapped_values = [ mapping [ col_data ] for el in col_data ] #NEWLINE# T_uncast_array [ : , col_idx ] = mapped_values #NEWLINE# #UNINDENT# T = numpy . array ( T_uncast_array , dtype = float ) . tolist ( ) #NEWLINE# return T