# config¶

This module holds the Nutils global configuration, stored as (immutable) attributes. To inspect the current configuration, use print() or vars() on this module. The configuration can be changed temporarily by calling this module with the new settings passed as keyword arguments and entering the returned context. The old settings are restored as soon as the context is exited. Example:

>>> from nutils import config
>>> config.verbose
4
>>> with config(verbose=2, nprocs=4):
...   # The configuration has been updated.
...   config.verbose
2
>>> # Exiting the context reverts the changes:
>>> config.verbose
4


Note

The default entry point for Nutils scripts nutils.cli.run() (and nutils.cli.choose()) will read user configuration from disk.

Important

The configuration is not thread-safe: changing the configuration inside a thread changes the process wide configuration.

The following configuration properties are used in Nutils.

nutils.config.nprocs

Controls the number of processes to use for computing integrals (nutils.topology.Topology.integrate()) and a few other expensive and parallelizable functions.

Defaults to 1.

nutils.config.verbose

Controls the level of verbosity of loggers. Log entries with a level higher than verbose are omitted. The levels are 1: error, 2: warning, 3: user, 4: info and 5: debug.

Defaults to 4: info.

nutils.config.dot

If True, nutils.sample.Sample.integrate() and :meth:nutils.sample.Sample.eval log a visualization of the function tree that is being evaluated or integrated.

Defaults to False.

The following properties are only used in nutils.cli.run() and nutils.cli.choose().

nutils.config.outrootdir

Defines the root directory for general output.

Defaults to '~/public_html'

nutils.config.outdir

Defines the output directory for the HTML log and plots. Relative paths are relative with respect to the current working directory (see os.getcwd()).

Defaults to '<outrootdir>/<scriptname>/<YY/MM/DD/HH-MM-SS>'

nutils.config.cache

Controls on-disk caching. If True, functions decorated with nutils.cache.function() (e.g. nutils.topology.Topology.integrate()) and subclasses of nutils.cache.Recursion (e.g. nutils.solver.thetamethod) are automatically cached.

Defaults to False.

nutils.config.cachedir

Defines the location of the on-disk cache (see cache) relative to <outrootdir>/<scriptname>.

Defaults to 'cache'.

If not empty, the symlinks '<outrootdir>/<symlink>' and '<outrootdir>/<scriptname>/<symlink>' will be created, both pointing to '<outrootdir>/<scriptname>/<YY/MM/DD/HH-MM-SS>'.

Defaults to ''.

nutils.config.richoutput

Controls whether or not the console logger should output rich text or plain text.

Defaults to True if sys.stdout is attached to a terminal (i.e. sys.stdout.isatty() returns true), otherwise False.

nutils.config.htmloutput

If True the HTML logger is enabled and written to '<outrootdir>/<scriptname>/<YY/MM/DD/HH-MM-SS>/log.html'

Defaults to True.

nutils.config.pdb

If True the debugger will be invoked when an exception reaches nutils.cli.run() or nutils.cli.choose().

Defaults to False.

nutils.config.matrix

A comma-separated list of matrix backends. The first one available is activated. The names — the case is irrelevant – correspond to subclasses of nutils.matrix.Backend. Use nutils.matrix.Backend.__subclasses__() to list the available backends.

Defauls to 'mkl,scipy,numpy'`.