pydft_qmmm.utils.descriptor

Helpful descriptors for caching and plugin loading.

Functions

pluggable_method(func)

Create a pluggable method that applies plugins in reverse order.

system_cache(*attributes[, obj_is_system])

Create a cached method that resets when the system changes.

pydft_qmmm.utils.descriptor.pluggable_method(func)[source]

Create a pluggable method that applies plugins in reverse order.

Parameters:

func (Callable[[Concatenate[TypeVar(Class), ParamSpec(P, bound= None)]], TypeVar(R)]) – The method to wrap.

Return type:

_PluggableMethod

Returns:

A descriptor class that can be updated with additional wrapper functions, which are applied in reverse order to ensure that the first wrapper may apply the outermost changes.

pydft_qmmm.utils.descriptor.system_cache(*attributes, obj_is_system=False)[source]

Create a cached method that resets when the system changes.

Parameters:
  • attributes (str) – The name of the system attributes for which the cache will reset.

  • obj_is_system (bool, default: False) – Whether the object is the system or merely contains a system object.

Return type:

Callable[[Callable[[Concatenate[TypeVar(Class), ParamSpec(P, bound= None)]], TypeVar(R)]], _Descriptor]

Returns:

A function that takes a bound method and returns a descriptor object that implements the caching.