Global Settings#
import preliz as pz
Some of the PreliZ default values are regulated by preliz.rcParams, a class similar to a dictionary storing key-value pairs inspired by the one in matplotlib and ArviZ. It is similar to a dictionary and not a dictionary though because all keys are fixed, and each key has associated a validation function to help prevent setting nonsensical defaults.
Preliz Configuration File#
The rcParams class is generated and populated at import time. PreliZ checks several locations for a file named prelizrc and, if found, prefers those settings over the library ones.
The locations checked are the following:
Current working directory,
os.getcwd()Location indicated by
PRELIZ_DATAenvironment variableThe third and last location checked is OS dependent:
On Linux:
$XDG_CONFIG_HOME/prelizif exists, otherwise~/.config/preliz/Elsewhere:
~/.preliz/
The file is a simple text file with a structure similar to the following:
stats.ci_kind : eti
stats.ci_prob : 0.89
All available keys are listed below. The prelizrc file can have any subset of the keys, it isn’t necessary to include them all. For those keys without a user defined default, the library one is used.
To find out the current settings, you can use:
pz.rcParams
RcParams({'plots.show_plot': True,
'stats.ci_kind': 'eti',
'stats.ci_prob': 0.89})
Context manager#
A context manager is also available to temporarily change the default settings.
with pz.rc_context({"plots.show_plot": False}):
pz.maxent(pz.Normal())
The context manager accepts a dictionary, a file path, or both.