popelier-group / ichor

Computational Chemistry Data Management Library for Machine Learning Force Field Development
https://ichor.readthedocs.io/
MIT License
9 stars 10 forks source link

Globals v2 #29

Closed MattBurn closed 3 years ago

MattBurn commented 3 years ago

Refactored Globals to make it easier to use and less error prone.

The previous version of Globals meant you had to have the knowledge that Global variables were in fact a wrapper around a variable and in fact an instance of GlobalVariable. This caused many bugs such as:

GLOBALS.METHOD = "B3LYP"
x = GLOBALS.METHOD == "B3LYP" # x would be False

With previous versions of Globals, you would have to do this:

GLOBALS.METHOD = "B3LYP"
x = str(GLOBALS.METHOD) == "B3LYP" # x would be True

This has been fixed in the most recent version by removing GlobalVariable and instead evaluating and converting types using typ hints and Globals are now class variables.

Naming of preprocessing steps for Global variables have also been updated, where pre_modifiers and modifiers are now called parsers and formatters respectively. There is also a checker for variables if needed which throw a ValueError if an incorrect value is passed to the variable. This is to make it easier for the developer to handle Global variables correctly and to reduce the amount of bugs associated to Global variables.