nubase_database_sgl¶
- class reactions.nubase_database_sgl¶
Bases:
objectObject to serve as an interface with the NuBase database. This object is declared as a singleton, using a single database file that can be modified using the
set_database_path()function. This ensures that reactions are composed of NuBase elements from the same file. The database can make use of an internal cache to avoid reading from the file many times.Methods Summary
__call__(arg)Access an element of the database by name or NuBase ID
Extract all the elements to a list.
Clear the internal cache, removing also user-registered elements
Disable the internal cache
Enable the internal cache.
Get the path to the database file
Register a new element in the database.
set_database_path(path)Set the path to the database file.
Methods Documentation
- __call__(arg)¶
Access an element of the database by name or NuBase ID
- Parameters
- Returns
Corresponding element
- Return type
- Raises
reactions.LookupError – If the element is not found
- all_elements()¶
Extract all the elements to a list. This includes all those elements registered by the user.
- Returns
All the elements
- Return type
- clear_cache()¶
Clear the internal cache, removing also user-registered elements
- disable_cache()¶
Disable the internal cache
- enable_cache()¶
Enable the internal cache. All the elements will be loaded in memory.
- get_database_path()¶
Get the path to the database file
- Returns
Path to the database file
- Return type
- register_element()¶
Register a new element in the database. Arguments can be either a single NuBase element object or the arguments to the constructor of
reactions.nubase_element.
- set_database_path(path)¶
Set the path to the database file. If the cache is enabled, reloads the data. If the cache is enabled, elements are reloaded in memory.
- Parameters
path – Path to the database file.