obs_factory
Factory class for generating observables
- class MDMC.trajectory_analysis.observables.obs_factory.ObservableFactory[source]
Provides a factory for creating an
Observable
. Any module within the observables submodule can be created with a string of the class name, as long as it is a subclass ofObservable
.- classmethod create_observable(name: str) Observable [source]
Creates an
Observable
object from a module nameThe
Observable
object must be registered with theObservableFactory
- Parameters:
name (str) – The name of the module with which the
Observable
is registered- Returns:
An
Observable
object- Return type:
- classmethod get_observable(name: str) Type[Observable] [source]
Gets an
Observable
class from a registry name- Parameters:
name (str) – The name of the module with which the
Observable
is registered- Returns:
A subclass of
Observable
- Return type:
cls
- classmethod register(names: str | Iterable) Callable [source]
A class level decorator for registering Observable classes
The names of the modules with which the Observable is registered should be the parameter passed to the decorator.
- Parameters:
names (str) – The names of the modules with which the Observable is registered
Example
To register the
SQw
class withObservableFactory
:@ObservableFactory.register('SQw') class SQw(Observable):