OpenMPCD
Public Member Functions | List of all members
MPCDAnalysis.Configuration.Configuration Class Reference

Public Member Functions

def __init__ (self, source=None, canonicalize=True)
 
def createGroup (self, name)
 
def isEquivalent (self, rhs, pathTranslators=[])
 
def get (self, key)
 
def getAsFlatDictionary (self)
 
def getDifferencesAsFlatDictionary (self, rhs)
 
def saveToParameterFile (self, path, additionalParameters={})
 
def __getitem__ (self, key)
 
def __setitem__ (self, key, value)
 
def __delitem__ (self, key)
 
def __contains__ (self, key)
 
def __repr__ (self)
 

Detailed Description

Represents an OpenMPCD configuration.

Configurations are assumed to be in the libconfig++ format.

Definition at line 7 of file Configuration.py.

Constructor & Destructor Documentation

◆ __init__()

def MPCDAnalysis.Configuration.Configuration.__init__ (   self,
  source = None,
  canonicalize = True 
)
    The constructor.

    @param[in] source
               If `None`, constructs an empty configuration.
               If the parameter is a string that corresponds to a file, it
               is loaded as the configuration file.
               If the string corresponds to a directory, it is assumed that
               this directory contains a file `config.txt`, which is loaded.
               Otherwise, it is assumed that the parameter contains a string
               representation of a configuration.
    @param[in] canonicalize
               Set to true to canonicalize the input configuration, i.e.
               transform it such that deprecated configuration settings are
               translated into their new equivalents.

Definition at line 26 of file Configuration.py.

Member Function Documentation

◆ __contains__()

def MPCDAnalysis.Configuration.Configuration.__contains__ (   self,
  key 
)
    Returns whether the given configuration `key` has been set.

    @throw TypeError
           Throws if `key` is not an instance of `str`.

    @param[in] key
               The setting to look up, as a string.

Definition at line 508 of file Configuration.py.

◆ __delitem__()

def MPCDAnalysis.Configuration.Configuration.__delitem__ (   self,
  key 
)
    Deletes the given setting recursively, if it exists.

    @throw TypeError
           Throws if `key` is not an instance of `str`.

    @param[in] key
               The setting to delete, as a string.

Definition at line 480 of file Configuration.py.

◆ __getitem__()

def MPCDAnalysis.Configuration.Configuration.__getitem__ (   self,
  key 
)
    Returns the value of the given key.

    @throw TypeError
           Throws if `key` is not of type `str`.
    @throw KeyError
           Throws if `key` is malformed or does not exist.

    @param[in] key
               The key to retrieve.

Definition at line 352 of file Configuration.py.

◆ __repr__()

def MPCDAnalysis.Configuration.Configuration.__repr__ (   self)
    Returns a `str` representation of this instance.

    This representation can be used to construct another instance of this
    class that is equivalent to this instance.

Definition at line 557 of file Configuration.py.

◆ __setitem__()

def MPCDAnalysis.Configuration.Configuration.__setitem__ (   self,
  key,
  value 
)
    Sets the given configuration key to the given value.

    Groups will be created as needed, if they do not exist already.

    @throw TypeError
           Throws if `key` is not of type `str`.
    @throw KeyError
           Throws if `key` is malformed.

    @param[in] key
               The configuration key.
    @param[in] value
               The configuration value.

Definition at line 430 of file Configuration.py.

◆ createGroup()

def MPCDAnalysis.Configuration.Configuration.createGroup (   self,
  name 
)
    Creates a group of the given name, if it does not exist, and returns it.

    This will create groups recursively, if necessary.

Definition at line 51 of file Configuration.py.

◆ get()

def MPCDAnalysis.Configuration.Configuration.get (   self,
  key 
)
    Alias for `__getitem__`, which makes the interface more compatible to
    `pylibconfig2.Config`.

Definition at line 184 of file Configuration.py.

◆ getAsFlatDictionary()

def MPCDAnalysis.Configuration.Configuration.getAsFlatDictionary (   self)
    Returns this configuration as a dictionary, with each key being a
    setting name (including the names of the parent setting groups, lists,
    etc.), and the corresponding dictionary value being the setting's value.

    Empty groups, lists, and arrays will have `None` as their value.

Definition at line 197 of file Configuration.py.

◆ getDifferencesAsFlatDictionary()

def MPCDAnalysis.Configuration.Configuration.getDifferencesAsFlatDictionary (   self,
  rhs 
)
    Returns a dictionary, the keys of which are exactly the setting names
    that appear in either exactly one of `self` and `rhs`, or occur in both,
    but with different values.

    Each key's value is a list of two lists; the first corresponding to
    `self`, the second to `rhs`. These lists are empty if the setting is not
    set in the corresponding configuration, and otherwise contain the value
    that is set in the corresponding configuration.

    Setting names and values are understood as in `getAsFlatDictionary`.

    @param[in] rhs
               The right-hand-side instance of this class.

Definition at line 249 of file Configuration.py.

◆ isEquivalent()

def MPCDAnalysis.Configuration.Configuration.isEquivalent (   self,
  rhs,
  pathTranslators = [] 
)
    Returns whether this configuration is equivalent to `rhs`, i.e. if all
    settings in this configuration exist and have the same values in `rhs`
    and vice versa.

    This method does not discriminate what `libconfig` calls arrays and
    lists.

    @throw TypeError
           Throws if `rhs` is not of type `Configuration`.
    @throw TypeError
           Throws if `pathTranslators` is not a list of elements that
           `callable()` returns `True` for.

    @param[in] rhs
               The instance to compare to.
    @param[in] pathTranslators
               Any configuration value string (on both this instance and
               `rhs`) will be successively replaced by the results of
               calling the functions in `pathTranslators` on that string.

Definition at line 99 of file Configuration.py.

◆ saveToParameterFile()

def MPCDAnalysis.Configuration.Configuration.saveToParameterFile (   self,
  path,
  additionalParameters = {} 
)
    Saves the configuration settings in a file with the given `path`.

    The first line contains the setting names, ordered lexicographically and
    separated by tab characters;
    the second line contains the corresponding values, with string values
    enclosed in curly braces, empty groups being represented by the string
    (not enclosed in curly braces) `None`,
    and with boolean values being represented by the strings `true` and
    `false`.

    This format is supposed to be readable by the `LaTeX` package
    `pgfplotstable`.

    @throw TypeError
           Throws if any argument has an invalid type.

    @param[in] path
               The file path to save the output to, as a string.
    @param[in] additionalParameters
               A dictionary containing, the keys of which are strings that
               describe addition parameters to write to the file, while the
               repsective values describe the parameter values.

Definition at line 297 of file Configuration.py.


The documentation for this class was generated from the following file: