Source code for pycif.utils.classes.simulators

from types import MethodType

from ...utils.check.errclass import PluginError
from .baseclass import Plugin


[docs] class Simulator(Plugin): """Plugin type for ensemble or Monte Carlo simulators. Provides the :meth:`simul` interface used to run a batch of forward simulations for uncertainty quantification or sensitivity analysis. Concrete implementations live in ``pycif/plugins/simulators/``. """
[docs] def initiate_template(self): """Initialise the Simulator plugin template. Loads the registered simulator module and attaches ``simul`` as a bound method on this instance. """ super(Simulator, self).initiate_template( plg_type="simulator", default_functions={"simul": True} )
[docs] @classmethod def register_plugin(cls, name, version, module, subtype="", **kwargs): """Register a module for a plugin and version with possibly options Args: name (str): name of the plugin version (str): version of the plugin module (types.ModuleType): module defining the interface between pyCIF and the plugin plugin_type (str): type of plugin **kwargs (dictionary): default options for module """ super(Simulator, cls).register_plugin( name, version, module, plugin_type="simulator", subtype=subtype )
[docs] def simul(self, *args, **kwargs): """Default empty simul method""" raise PluginError("This is the default empty simul method")