quantEM has a global configuration system (quantem.core.config, modeled on Dask’s config) controlling the compute device, numerical precision, and visualization defaults.
Reading and setting values¶
from quantem.core import config
config.get("device")
config.get("viz.cmap")
config.set({"precision": "float64"})config.set also works as a context manager for temporary overrides:
with config.set({"device": "cuda:1"}):
...Code inside the block runs on cuda:1, and the previous value is restored on exit.
Persistent configuration¶
The active configuration can be written to a YAML file that is read back on import:
config.write()This writes ~/.config/quantem/config.yaml.
The configuration directory can be relocated with the QUANTEM_CONFIG environment variable.
Main keys¶
| Key | Default | Meaning |
|---|---|---|
device | cpu | Compute device (see GPU configuration) |
precision | float32 | Float precision (float32 or float64) |
dtype_real / dtype_complex | float32 / complex64 | Real and complex dtypes |
verbose | 1 | Global verbosity |
viz.cmap | gray | Default image colormap |
viz.phase_cmap | magma | Default colormap for phase images |
viz.real_space_units | A | Default real-space units |
viz.reciprocal_space_units | A^-1 | Default reciprocal-space units |
viz.colors.set / viz.colors.paired | (lists) | Categorical color cycles for plots |
mkl.threads | 2 | MKL thread count |
cupy.fft-cache-size | 0 MB | CuPy FFT plan cache size |