Configuration for pyAgrum¶
Configuration for pyAgrum is centralized in an object gum.config, singleton of the class PyAgrumConfiguration.
-
class
pyAgrum.PyAgrumConfiguration¶ PyAgrumConfiguration is a the pyAgrum configuration singleton. The configuration is build as a classical ConfigParser with read-only structure. Then a value is adressable using a double key:
[section,key].See this notebook.
Examples
>>> gum.config['dynamicBN','default_graph_size']=10 >>> gum.config['dynamicBN','default_graph_size'] "10"
-
diff()¶ print the diff between actual configuration and the defaults. This is what is saved in the file
pyagrum.iniby the method PyAgrumConfiguration.save()
-
get(section, option)¶ Give the value associated to section.option. Preferably use
__getitem__and__setitem__.Examples
>>> gum.config['dynamicBN','default_graph_size']=10 >>> gum.config['dynamicBN','default_graph_size'] "10"
- Arguments:
- section {str} – the section option {str} – the property
- Returns:
- str – the value (as string)
-
grep(search)¶ grep in the configuration any section or properties matching the argument. If a section match the argume, all the section is displayed.
- Arguments:
- search {str} – the string to find
-
load()¶ load pyagrum.ini in the current directory, and change the properties if needed
- Raises:
- FileNotFoundError: if there is no pyagrum.ini in the current directory
-
reset()¶ back to defaults
-
save()¶ Save the diff with the defaults in
pyagrum.iniin the current directory
-
set(section, option, value, no_hook=False)¶ set a property in a section. Preferably use
__getitem__and__setitem__.Examples
>>> gum.config['dynamicBN','default_graph_size']=10 >>> gum.config['dynamicBN','default_graph_size'] "10"
- Arguments:
- section {str} – the section name (has to exist in defaults) option {str} – the option/property name (has to exist in defaults) value {str} – the value (will be store as string) no_hook {bool} – (optional) should this call trigger the hooks ?
- Raises:
- SyntaxError: if the secion name or the property name does not exist
-