#NEWLINE# def get_tables( self ) : #NEWLINE# #INDENT# '\n        Adds tables to the network.\n\n        Example\n        -------\n        >>> writer = UAIWriter(model)\n        >>> writer.get_tables()\n        ' #NEWLINE# if isinstance ( self . model , BayesianModel ) : #NEWLINE# #INDENT# cpds = self . model . get_cpds ( ) #NEWLINE# cpds . sort ( key = ( lambda x : x . variable ) ) #NEWLINE# tables = [ ] #NEWLINE# for cpd in cpds : #NEWLINE# #INDENT# values = list ( map ( str , cpd . values . ravel ( ) ) ) #NEWLINE# tables . append ( values ) #NEWLINE# #UNINDENT# return tables #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( self . model , MarkovModel ) : #NEWLINE# #INDENT# factors = self . model . get_factors ( ) #NEWLINE# tables = [ ] #NEWLINE# for factor in factors : #NEWLINE# #INDENT# values = list ( map ( str , factor . values . ravel ( ) ) ) #NEWLINE# tables . append ( values ) #NEWLINE# #UNINDENT# return tables #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise TypeError ( 'Model must be an instance of Markov or Bayesian model.' )