parameters: (self, mtd, bas, tableplan, benchmark='default',
                        opt=['CP'], err=['mae'], sset=['default'], dbse=None,
                        opttarget=None,
                        failoninc=True,
                        xlimit=4.0, xlines=[0.0, 0.3, 1.0],
                        ialimit=2.0,
                        plotpath='autogen',
                        subjoin=True,
                        title=None, indextitle=None,
                        suppressblanks=False,
                        standalone=True, theme=None, filename=None)
docstring: Prepares dictionary of errors for all combinations of *mtd*, *opt*,
          *bas* with respect to model chemistry *benchmark*, mindful of *failoninc*.
          The general plan for the table, as well as defaults for landscape,
          footnotes, *title*, *indextitle, and *theme* are got from function
          *tableplan*. Once error dictionary is ready, it and all other arguments
          are passed along to textables.table_generic. Two arrays, one of table
          lines and one of index lines are returned unless *filename* is given,
          in which case they're written to file and a filedict returned.
docstring_summary: Prepares dictionary of errors for all combinations of *mtd*, *opt*,
          *bas* with respect to model chemistry *benchmark*, mindful of *failoninc*.
          The general plan for the table, as well as defaults for landscape,
          footnotes, *title*, *indextitle, and *theme* are got from function
          *tableplan*. Once error dictionary is ready, it and all other arguments
          are passed along to textables.table_generic. Two arrays, one of table
          lines and one of index lines are returned unless *filename* is given,
          in which case they're written to file and a filedict returned.
docstring_tokens: Prepares dictionary of errors for all combinations of * mtd * * opt * * bas * with respect to model chemistry * benchmark * mindful of * failoninc * . The general plan for the table as well as defaults for landscape footnotes * title * * indextitle and * theme * are got from function * tableplan * . Once error dictionary is ready it and all other arguments are passed along to textables . table_generic . Two arrays one of table lines and one of index lines are returned unless * filename * is given in which case they re written to file and a filedict returned .
function: def table_wrapper(self, mtd, bas, tableplan, benchmark='default',
                        opt=['CP'], err=['mae'], sset=['default'], dbse=None,
                        opttarget=None,
                        failoninc=True,
                        xlimit=4.0, xlines=[0.0, 0.3, 1.0],
                        ialimit=2.0,
                        plotpath='autogen',
                        subjoin=True,
                        title=None, indextitle=None,
                        suppressblanks=False,
                        standalone=True, theme=None, filename=None):
          """Prepares dictionary of errors for all combinations of *mtd*, *opt*,
          *bas* with respect to model chemistry *benchmark*, mindful of *failoninc*.
          The general plan for the table, as well as defaults for landscape,
          footnotes, *title*, *indextitle, and *theme* are got from function
          *tableplan*. Once error dictionary is ready, it and all other arguments
          are passed along to textables.table_generic. Two arrays, one of table
          lines and one of index lines are returned unless *filename* is given,
          in which case they're written to file and a filedict returned.
  
          """
          # get plan for table from *tableplan* and some default values
          kwargs = {'plotpath': plotpath,
                    'subjoin': subjoin,
                    'xlines': xlines,
                    'xlimit': xlimit,
                    'ialimit': ialimit}
          rowplan, columnplan, landscape, footnotes, \
          suggestedtitle, suggestedtheme = tableplan(**kwargs)
          #suggestedtitle, suggestedtheme = tableplan(plotpath=plotpath, subjoin=subjoin)
  
          # make figure files write themselves
          autothread = {}
          autoliliowa = {}
          if plotpath == 'autogen':
              for col in columnplan:
                  if col[3].__name__ == 'flat':
                      if col[4] and autothread:
                          print('TODO: merge not handled')
                      elif col[4] or autothread:
                          autothread.update(col[4])
                      else:
                          autothread = {'dummy': True}
                  elif col[3].__name__ == 'liliowa':
                      autoliliowa = {'dummy': True}
  
          # negotiate some defaults
          dbse = [self.dbse] if dbse is None else dbse
          theme = suggestedtheme if theme is None else theme
          title = suggestedtitle if title is None else title
          indextitle = title if indextitle is None else indextitle
          opttarget = {'default': ['']} if opttarget is None else opttarget
  
          def unify_options(orequired, opossible):
              """Perform a merge of options tags in *orequired* and *opossible* so
              that the result is free of duplication and has the mode at the end.
  
              """
              opt_combos = []
              for oreq in orequired:
                  for opos in opossible:
                      pieces = sorted(set(oreq.split('_') + opos.split('_')))
                      if '' in pieces:
                          pieces.remove('')
                      for mode in ['CP', 'unCP', 'SA']:
                          if mode in pieces:
                              pieces.remove(mode)
                              pieces.append(mode)
                      pieces = '_'.join(pieces)
                      opt_combos.append(pieces)
              return opt_combos
  
          # gather list of model chemistries for table
          mcs = ['-'.join(prod) for prod in itertools.product(mtd, opt, bas)]
          mc_translator = {}
          for m, o, b in itertools.product(mtd, opt, bas):
              nominal_mc = '-'.join([m, o, b])
              for oo in unify_options([o], opttarget['default']):
                  trial_mc = '-'.join([m, oo, b])
                  try:
                      perr = self.compute_statistics(trial_mc, benchmark=benchmark, sset='default',  # prob. too restrictive by choosing subset
                                                     failoninc=False, verbose=False, returnindiv=False)
                  except KeyError as e:
                      continue
                  else:
                      mc_translator[nominal_mc] = trial_mc
                      break
              else:
                  mc_translator[nominal_mc] = None
  
          # compute errors
          serrors = {}
          for mc in mcs:
              serrors[mc] = {}
              for ss in self.sset.keys():
                  serrors[mc][ss] = {}
                  if mc_translator[mc] in self.mcs:
                      # Note: not handling when one component Wdb has one translated pattern and another another
                      perr = self.compute_statistics(mc_translator[mc], benchmark=benchmark, sset=ss,
                                                     failoninc=failoninc, verbose=False, returnindiv=False)
                      serrors[mc][ss][self.dbse] = format_errors(perr[self.dbse], mode=3)
                      if not failoninc:
                          mcsscounts = self.get_missing_reactions(mc_translator[mc], sset=ss)
                          serrors[mc][ss][self.dbse]['tgtcnt'] = mcsscounts[self.dbse][0]
                          serrors[mc][ss][self.dbse]['misscnt'] = len(mcsscounts[self.dbse][1])
                      if autothread:
                          if ('sset' in autothread and ss in autothread['sset']) or ('sset' not in autothread):
                              mcssplots = self.plot_flat(mc_translator[mc], benchmark=benchmark, sset=ss,
                                  failoninc=failoninc, color='sapt', xlimit=xlimit, xlines=xlines, view=False,
                                  saveas='flat_' + '-'.join([self.dbse, ss, mc]), relpath=True, graphicsformat=['pdf'])
                              serrors[mc][ss][self.dbse]['plotflat'] = mcssplots['pdf']
                      if autoliliowa and ss == 'default':
                              mcssplots = self.plot_liliowa(mc_translator[mc], benchmark=benchmark,
                                  failoninc=failoninc, xlimit=ialimit, view=False,
                                  saveas='liliowa_' + '-'.join([self.dbse, ss, mc]), relpath=True, graphicsformat=['pdf'])
                              serrors[mc][ss][self.dbse]['plotliliowa'] = mcssplots['pdf']
                      for db in self.dbdict.keys():
                          if perr[db] is None:
                              serrors[mc][ss][db] = None
                          else:
                              serrors[mc][ss][db] = format_errors(perr[db], mode=3)
                              if not failoninc:
                                  serrors[mc][ss][db]['tgtcnt'] = mcsscounts[db][0]
                                  serrors[mc][ss][db]['misscnt'] = len(mcsscounts[db][1])
                  else:
                      serrors[mc][ss][self.dbse] = format_errors(initialize_errors(), mode=3)
                      for db in self.dbdict.keys():
                          serrors[mc][ss][db] = format_errors(initialize_errors(), mode=3)
          for key in serrors.keys():
              print("""{:>35}{:>35}{}""".format(key, mc_translator[key], serrors[key]['default'][self.dbse]['mae']))
  
          # find indices that would be neglected in a single sweep over table_generic
          keysinplan = set(sum([col[-1].keys() for col in columnplan], rowplan))
          obvious = {'dbse': dbse, 'sset': sset, 'mtd': mtd, 'opt': opt, 'bas': bas, 'err': err}
          for key, vari in obvious.items():
              if len(vari) == 1 or key in keysinplan:
                  del obvious[key]
          iteroers = [(prod) for prod in itertools.product(*obvious.values())]
  
          # commence to generate LaTeX code
          tablelines = []
          indexlines = []
  
          if standalone:
              tablelines += textables.begin_latex_document()
  
          for io in iteroers:
              actvargs = dict(zip(obvious.keys(), [[k] for k in io]))
              nudbse = actvargs['dbse'] if 'dbse' in actvargs else dbse
              nusset = actvargs['sset'] if 'sset' in actvargs else sset
              numtd = actvargs['mtd'] if 'mtd' in actvargs else mtd
              nuopt = actvargs['opt'] if 'opt' in actvargs else opt
              nubas = actvargs['bas'] if 'bas' in actvargs else bas
              nuerr = actvargs['err'] if 'err' in actvargs else err
  
              table, index = textables.table_generic(
                  mtd=numtd, bas=nubas, opt=nuopt, err=nuerr, sset=nusset, dbse=nudbse,
                  rowplan=rowplan, columnplan=columnplan, serrors=serrors,
                  plotpath='' if plotpath == 'autogen' else plotpath,
                  subjoin=subjoin,
                  title=title, indextitle=indextitle,
                  suppressblanks=suppressblanks,
                  landscape=landscape, footnotes=footnotes,
                  standalone=False, theme=theme)
  
              tablelines += table
              tablelines.append('\n\n')
              indexlines += index
  
          if standalone:
              tablelines += textables.end_latex_document()
  
          # form table and index return structures
          if filename is None:
              return tablelines, indexlines
          else:
              if filename.endswith('.tex'):
                  filename = filename[:-4]
              with open(filename + '.tex', 'w') as handle:
                  handle.write('\n'.join(tablelines))
              with open(filename + '_index.tex', 'w') as handle:
                  handle.write('\n'.join(indexlines))
              print("""\n  LaTeX index written to {filename}_index.tex\n"""
                    """  LaTeX table written to {filename}.tex\n"""
                    """  >>> pdflatex {filename}\n"""
                    """  >>> open /Applications/Preview.app {filename}.pdf\n""".format(filename=filename))
              filedict = {'data': os.path.abspath(filename) + '.tex',
                          'index': os.path.abspath(filename + '_index.tex')}
              return filedict
function_tokens: def table_wrapper ( self , mtd , bas , tableplan , benchmark = 'default' , opt = [ 'CP' ] , err = [ 'mae' ] , sset = [ 'default' ] , dbse = None , opttarget = None , failoninc = True , xlimit = 4.0 , xlines = [ 0.0 , 0.3 , 1.0 ] , ialimit = 2.0 , plotpath = 'autogen' , subjoin = True , title = None , indextitle = None , suppressblanks = False , standalone = True , theme = None , filename = None ) : # get plan for table from *tableplan* and some default values kwargs = { 'plotpath' : plotpath , 'subjoin' : subjoin , 'xlines' : xlines , 'xlimit' : xlimit , 'ialimit' : ialimit } rowplan , columnplan , landscape , footnotes , suggestedtitle , suggestedtheme = tableplan ( * * kwargs ) #suggestedtitle, suggestedtheme = tableplan(plotpath=plotpath, subjoin=subjoin) # make figure files write themselves autothread = { } autoliliowa = { } if plotpath == 'autogen' : for col in columnplan : if col [ 3 ] . __name__ == 'flat' : if col [ 4 ] and autothread : print ( 'TODO: merge not handled' ) elif col [ 4 ] or autothread : autothread . update ( col [ 4 ] ) else : autothread = { 'dummy' : True } elif col [ 3 ] . __name__ == 'liliowa' : autoliliowa = { 'dummy' : True } # negotiate some defaults dbse = [ self . dbse ] if dbse is None else dbse theme = suggestedtheme if theme is None else theme title = suggestedtitle if title is None else title indextitle = title if indextitle is None else indextitle opttarget = { 'default' : [ '' ] } if opttarget is None else opttarget def unify_options ( orequired , opossible ) : """Perform a merge of options tags in *orequired* and *opossible* so
              that the result is free of duplication and has the mode at the end.
  
              """ opt_combos = [ ] for oreq in orequired : for opos in opossible : pieces = sorted ( set ( oreq . split ( '_' ) + opos . split ( '_' ) ) ) if '' in pieces : pieces . remove ( '' ) for mode in [ 'CP' , 'unCP' , 'SA' ] : if mode in pieces : pieces . remove ( mode ) pieces . append ( mode ) pieces = '_' . join ( pieces ) opt_combos . append ( pieces ) return opt_combos # gather list of model chemistries for table mcs = [ '-' . join ( prod ) for prod in itertools . product ( mtd , opt , bas ) ] mc_translator = { } for m , o , b in itertools . product ( mtd , opt , bas ) : nominal_mc = '-' . join ( [ m , o , b ] ) for oo in unify_options ( [ o ] , opttarget [ 'default' ] ) : trial_mc = '-' . join ( [ m , oo , b ] ) try : perr = self . compute_statistics ( trial_mc , benchmark = benchmark , sset = 'default' , # prob. too restrictive by choosing subset failoninc = False , verbose = False , returnindiv = False ) except KeyError as e : continue else : mc_translator [ nominal_mc ] = trial_mc break else : mc_translator [ nominal_mc ] = None # compute errors serrors = { } for mc in mcs : serrors [ mc ] = { } for ss in self . sset . keys ( ) : serrors [ mc ] [ ss ] = { } if mc_translator [ mc ] in self . mcs : # Note: not handling when one component Wdb has one translated pattern and another another perr = self . compute_statistics ( mc_translator [ mc ] , benchmark = benchmark , sset = ss , failoninc = failoninc , verbose = False , returnindiv = False ) serrors [ mc ] [ ss ] [ self . dbse ] = format_errors ( perr [ self . dbse ] , mode = 3 ) if not failoninc : mcsscounts = self . get_missing_reactions ( mc_translator [ mc ] , sset = ss ) serrors [ mc ] [ ss ] [ self . dbse ] [ 'tgtcnt' ] = mcsscounts [ self . dbse ] [ 0 ] serrors [ mc ] [ ss ] [ self . dbse ] [ 'misscnt' ] = len ( mcsscounts [ self . dbse ] [ 1 ] ) if autothread : if ( 'sset' in autothread and ss in autothread [ 'sset' ] ) or ( 'sset' not in autothread ) : mcssplots = self . plot_flat ( mc_translator [ mc ] , benchmark = benchmark , sset = ss , failoninc = failoninc , color = 'sapt' , xlimit = xlimit , xlines = xlines , view = False , saveas = 'flat_' + '-' . join ( [ self . dbse , ss , mc ] ) , relpath = True , graphicsformat = [ 'pdf' ] ) serrors [ mc ] [ ss ] [ self . dbse ] [ 'plotflat' ] = mcssplots [ 'pdf' ] if autoliliowa and ss == 'default' : mcssplots = self . plot_liliowa ( mc_translator [ mc ] , benchmark = benchmark , failoninc = failoninc , xlimit = ialimit , view = False , saveas = 'liliowa_' + '-' . join ( [ self . dbse , ss , mc ] ) , relpath = True , graphicsformat = [ 'pdf' ] ) serrors [ mc ] [ ss ] [ self . dbse ] [ 'plotliliowa' ] = mcssplots [ 'pdf' ] for db in self . dbdict . keys ( ) : if perr [ db ] is None : serrors [ mc ] [ ss ] [ db ] = None else : serrors [ mc ] [ ss ] [ db ] = format_errors ( perr [ db ] , mode = 3 ) if not failoninc : serrors [ mc ] [ ss ] [ db ] [ 'tgtcnt' ] = mcsscounts [ db ] [ 0 ] serrors [ mc ] [ ss ] [ db ] [ 'misscnt' ] = len ( mcsscounts [ db ] [ 1 ] ) else : serrors [ mc ] [ ss ] [ self . dbse ] = format_errors ( initialize_errors ( ) , mode = 3 ) for db in self . dbdict . keys ( ) : serrors [ mc ] [ ss ] [ db ] = format_errors ( initialize_errors ( ) , mode = 3 ) for key in serrors . keys ( ) : print ( """{:>35}{:>35}{}""" . format ( key , mc_translator [ key ] , serrors [ key ] [ 'default' ] [ self . dbse ] [ 'mae' ] ) ) # find indices that would be neglected in a single sweep over table_generic keysinplan = set ( sum ( [ col [ - 1 ] . keys ( ) for col in columnplan ] , rowplan ) ) obvious = { 'dbse' : dbse , 'sset' : sset , 'mtd' : mtd , 'opt' : opt , 'bas' : bas , 'err' : err } for key , vari in obvious . items ( ) : if len ( vari ) == 1 or key in keysinplan : del obvious [ key ] iteroers = [ ( prod ) for prod in itertools . product ( * obvious . values ( ) ) ] # commence to generate LaTeX code tablelines = [ ] indexlines = [ ] if standalone : tablelines += textables . begin_latex_document ( ) for io in iteroers : actvargs = dict ( zip ( obvious . keys ( ) , [ [ k ] for k in io ] ) ) nudbse = actvargs [ 'dbse' ] if 'dbse' in actvargs else dbse nusset = actvargs [ 'sset' ] if 'sset' in actvargs else sset numtd = actvargs [ 'mtd' ] if 'mtd' in actvargs else mtd nuopt = actvargs [ 'opt' ] if 'opt' in actvargs else opt nubas = actvargs [ 'bas' ] if 'bas' in actvargs else bas nuerr = actvargs [ 'err' ] if 'err' in actvargs else err table , index = textables . table_generic ( mtd = numtd , bas = nubas , opt = nuopt , err = nuerr , sset = nusset , dbse = nudbse , rowplan = rowplan , columnplan = columnplan , serrors = serrors , plotpath = '' if plotpath == 'autogen' else plotpath , subjoin = subjoin , title = title , indextitle = indextitle , suppressblanks = suppressblanks , landscape = landscape , footnotes = footnotes , standalone = False , theme = theme ) tablelines += table tablelines . append ( '\n\n' ) indexlines += index if standalone : tablelines += textables . end_latex_document ( ) # form table and index return structures if filename is None : return tablelines , indexlines else : if filename . endswith ( '.tex' ) : filename = filename [ : - 4 ] with open ( filename + '.tex' , 'w' ) as handle : handle . write ( '\n' . join ( tablelines ) ) with open ( filename + '_index.tex' , 'w' ) as handle : handle . write ( '\n' . join ( indexlines ) ) print ( """\n  LaTeX index written to {filename}_index.tex\n""" """  LaTeX table written to {filename}.tex\n""" """  >>> pdflatex {filename}\n""" """  >>> open /Applications/Preview.app {filename}.pdf\n""" . format ( filename = filename ) ) filedict = { 'data' : os . path . abspath ( filename ) + '.tex' , 'index' : os . path . abspath ( filename + '_index.tex' ) } return filedict