original_docstring: 
      Using the specification from run_settings, will
      substitute in different values into a YAML file
      and write the new YAML file to scratch.
      
docstring: Using the specification from run_settings, will
  substitute in different values into a YAML file
  and write the new YAML file to scratch.
docstring_tokens: Using the specification from run_settings will substitute in different values into a YAML file and write the new YAML file to scratch .
code: def format_yaml(run_settings,settings):
      """
      Using the specification from run_settings, will
      substitute in different values into a YAML file
      and write the new YAML file to scratch.
      """
      # open the YAML template
      with open(os.path.join("yaml_templates",run_settings['yaml file'])) as y:
          yaml_string = y.read()
      # sub in the following things for default: settings_path, run_settings_path,
      # final_shape, n_classes, save_path
      hier = neukrill_net.encoding.get_hierarchy(settings)
      hier_group_sizes = {"n_classes_{0}".format(i+1) : n for i, n
                          in enumerate([len(el) for el in hier])}
      run_settings.update(hier_group_sizes)
      run_settings["n_classes"] = len(settings.classes)
      # legacy rename, to make sure it's in there
      run_settings["save_path"] = run_settings['pickle abspath']
      # make new dictionary for substitution
      sub = {}
      sub.update(run_settings)
      sub.update(run_settings['preprocessing'])
      sub.update(run_settings['preprocessing'].get('normalise',{}))
      # time for some crude string parsing
      yaml_string = yaml_string%(sub)
      # write the new yaml to the data directory, in a yaml_settings subdir
      yamldir = os.path.join(settings.data_dir,"yaml_settings")
      if not os.path.exists(yamldir):
          os.mkdir(yamldir)
      yaml_path = os.path.join(yamldir,run_settings["filename"]+
              run_settings['yaml file'].split(".")[0]+".yaml")
      try:
          with open(yaml_path, "w") as f:
              f.write(yaml_string)
      except IOError:
          warnings.warn("Could not write full YAML specification to scratch."
                        " Not required for reproducibility, but can be used "
                        "with Pylearn2 on its own, so may be useful.")
      return yaml_string
code_tokens: def format_yaml ( run_settings , settings ) : with open ( os . path . join ( "yaml_templates" , run_settings [ 'yaml file' ] ) ) as y : yaml_string = y . read ( ) hier = neukrill_net . encoding . get_hierarchy ( settings ) hier_group_sizes = { "n_classes_{0}" . format ( i + 1 ) : n for i , n in enumerate ( [ len ( el ) for el in hier ] ) } run_settings . update ( hier_group_sizes ) run_settings [ "n_classes" ] = len ( settings . classes ) run_settings [ "save_path" ] = run_settings [ 'pickle abspath' ] sub = { } sub . update ( run_settings ) sub . update ( run_settings [ 'preprocessing' ] ) sub . update ( run_settings [ 'preprocessing' ] . get ( 'normalise' , { } ) ) yaml_string = yaml_string % ( sub ) yamldir = os . path . join ( settings . data_dir , "yaml_settings" ) if not os . path . exists ( yamldir ) : os . mkdir ( yamldir ) yaml_path = os . path . join ( yamldir , run_settings [ "filename" ] + run_settings [ 'yaml file' ] . split ( "." ) [ 0 ] + ".yaml" ) try : with open ( yaml_path , "w" ) as f : f . write ( yaml_string ) except IOError : warnings . warn ( "Could not write full YAML specification to scratch." " Not required for reproducibility, but can be used " "with Pylearn2 on its own, so may be useful." ) return yaml_string
short_docstring: Using the specification from run_settings, will
  substitute in different values into a YAML file
  and write the new YAML file to scratch.
short_docstring_tokens: Using the specification from run_settings will substitute in different values into a YAML file and write the new YAML file to scratch .
comment: """
      Using the specification from run_settings, will
      substitute in different values into a YAML file
      and write the new YAML file to scratch.
      """$SEP$# open the YAML template$SEP$# sub in the following things for default: settings_path, run_settings_path,$SEP$# final_shape, n_classes, save_path$SEP$# legacy rename, to make sure it's in there$SEP$# make new dictionary for substitution$SEP$# time for some crude string parsing$SEP$# write the new yaml to the data directory, in a yaml_settings subdir