tmancal74 / quantarhei

Open Quantum System Theory for Molecular Systems
MIT License
21 stars 16 forks source link

Enforcement of units and basis context usage #124

Open tmancal74 opened 1 year ago

tmancal74 commented 1 year ago

It is desirable not to allow functions that set physical values to be used outside the units context (energy_units etc.). These functions should raise an Exception if used without the context. Similarly, some functions should not be used inside the eigenbasis_of context. Again, an Exception should be raised if this context is applied on the function.

tmancal74 commented 1 year ago

The most elegant solution would be to implement decorators which decorate the functions for which the presence of context should be enforced (or prevented). The decorated function will detect the present of the context and through an exception if the context policy is breached.

tmancal74 commented 1 year ago

Simple detection of eigenbasis_of context is implemented. Wrappers prevent_basis_context and enforce_basis_context are available and working.

The new wrapper is not yet applied to anything as its presence will likely break several existing automated tests.

tmancal74 commented 1 year ago

Wrappers now successfully applied to CorrelationFunction. This object has to be created under the energy_units context.