Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforcement of units and basis context usage #124

Open
tmancal74 opened this issue Feb 26, 2023 · 3 comments
Open

Enforcement of units and basis context usage #124

tmancal74 opened this issue Feb 26, 2023 · 3 comments
Assignees

Comments

@tmancal74
Copy link
Owner

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 tmancal74 self-assigned this Feb 26, 2023
@tmancal74
Copy link
Owner Author

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
Copy link
Owner Author

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
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant