easyvvuq.encoders package

Submodules

easyvvuq.encoders.apply_fixtures module

easyvvuq.encoders.base module

Provided base class for all encoders and dictionary to register all imported encoders.

Encoders provide functions to convert generic problem space parameters lists into inputs for particular simulation codes.

ivar AVAILABLE_ENCODERS:
 Registers all imported encoders.
vartype AVAILABLE_ENCODERS:
 dict
class easyvvuq.encoders.base.BaseEncoder

Bases: easyvvuq.base_element.BaseElement

Baseclass for all EasyVVUQ encoders.

Skeleton encoder which establishes the format and provides the basis of our contract - provide an encode method to parse these and write relevant run file to a target directory.

static deserialize(encoderstr)
element_category()
element_name()
encode(params=None, target_dir='')

Takes list of generic parameter values from params and converts them into simulation input files (in target_dir).

Parameters:
  • params (dict or None) – Dictionary containing parameter names and values.
  • target_dir (str) – Path into which output will be written.
is_restartable()

easyvvuq.encoders.copy_encoder module

An encoder meant to simply copy a file to the input directory unchanged. It is meant to be used in combination with MultiBuilder encoder and possibly the DirectoryBuilder. It duplicates some functionality of the ApplyFixtures encoder but can be useful for very simple cases.

Examples

>>> multiencoder = uq.encoders.MultiEncoder(
      DirectoryBuilder(tree={"parent" : {"child1" : None, "child2" : None}}),
      CopyEncoder('/home/user/input1.conf', 'parent/child1/input1.conf')
      CopyEncoder('/home/user/input2.conf', 'parent/child1/input2.conf')
      CopyEncoder('/home/user/input3.conf', 'parent/child2/input3.conf')
      GenericEncoder(delimiter='$', template_fname='/home/user/template.in',
                     target_filename='parent/input.int'))
class easyvvuq.encoders.copy_encoder.CopyEncoder(source_filename, target_filename)

Bases: easyvvuq.encoders.base.BaseEncoder

An Encoder to copy an input file to a simulation.

Parameters:
  • source_filename (str) – a full path to some file that a simulation needs
  • target_filename (str) – a target filename inside the simulation directory
element_version()
encode(params={}, target_dir='')

Copy a file to target_dir.

Parameters:
  • params (dict) – keep empty, has no effect
  • target_dir (str) – target directory, full path
encoder_name = 'copy_encoder'
get_restart_dict()

easyvvuq.encoders.directory_builder module

class easyvvuq.encoders.directory_builder.DirectoryBuilder(tree)

Bases: easyvvuq.encoders.base.BaseEncoder

DirectoryBuilder builds the specified directory structure for a Run.

The dir structure is specified by the ‘tree’ parameter. This should be a dict of dicts, for example:

tree = {‘a’ : {‘b’ : {‘c’ : None, ‘d’ : None}}, ‘e’ : {‘f’ : None}}

Parameters:tree (dict of dicts) – The desired directory structure
create_dir_tree(dirtree, root)
element_version()
encode(params={}, target_dir='')

Builds the directory structure specified in self.tree into the target_dir directory

Parameters:
  • params (dict) – Parameter information in dictionary.
  • target_dir (str) – Path to directory where application input will be written.
encoder_name = 'directory_builder'
get_restart_dict()

easyvvuq.encoders.generic_template module

class easyvvuq.encoders.generic_template.GenericEncoder(template_fname, delimiter='$', target_filename='app_input.txt')

Bases: easyvvuq.encoders.base.BaseEncoder

GenericEncoder for substituting values into application template input.

element_version()
encode(params={}, target_dir='')

Substitutes params into a template application input, saves in target_dir

Parameters:
  • params (dict) – Parameter information in dictionary.
  • target_dir (str) – Path to directory where application input will be written.
encoder_name = 'generic_template'
get_restart_dict()
easyvvuq.encoders.generic_template.get_custom_template(template_txt, custom_delimiter='$')

easyvvuq.encoders.jinja_encoder module

class easyvvuq.encoders.jinja_encoder.JinjaEncoder(template_fname, target_filename='app_input.txt')

Bases: easyvvuq.encoders.base.BaseEncoder

JinjaEncoder for substituting values into application template input. Uses the jinja2 template system, which supports more complex expressions than the GenericEncoder. See https://jinja.palletsprojects.com/en/2.10.x/templates/ for template syntax.

element_version()
encode(params={}, target_dir='', fixtures=None)

Substitutes params into a template application input, saves in target_dir

Parameters:
  • params (dict) – Parameter information in dictionary.
  • target_dir (str) – Path to directory where application input will be written.
  • fixtures (dict) – Information of files/assets for fixture type parameters.
encoder_name = 'jinja_template'
get_restart_dict()

easyvvuq.encoders.multiencoder module

class easyvvuq.encoders.multiencoder.MultiEncoder(*encoders, serialized_list_of_encoders=None)

Bases: easyvvuq.encoders.base.BaseEncoder

element_version()
encode(params=None, target_dir='')

Applies all encoders in the list of encoders.

encoder_name = 'multiencoder'
get_restart_dict()
is_restartable()

Module contents