Debian Codegraph @

docs_sphinx/advanced/preferences.rst

raw
1 Preferences
2 ===========
3
4 Brian has a system of global preferences that affect how certain objects
5 behave. These can be set either in scripts by using the `prefs` object
6 or in a file. Each preference looks like ``codegen.cpp.compiler``, i.e. dotted
7 names.
8
9 Accessing and setting preferences
10 ---------------------------------
11 Preferences can be accessed and set either keyword-based or attribute-based.
12 The following are equivalent::
13
14 prefs['codegen.cpp.compiler'] = 'unix'
15 prefs.codegen.cpp.compiler = 'unix'
16
17 Using the attribute-based form can be particulary useful for interactive
18 work, e.g. in ipython, as it offers autocompletion and documentation.
19 In ipython, ``prefs.codegen.cpp?`` would display a docstring with all
20 the preferences available in the ``codegen.cpp`` category.
21
22 Preference files
23 ----------------
24
25 Preferences are stored in a hierarchy of files, with the following order
26 (each step overrides the values in the previous step but no error is raised
27 if one is missing):
28
29 * The user default are stored in ``~/.brian/user_preferences`` (which works on
30 Windows as well as Linux). The ``~`` symbol refers to the user directory.
31 * The file ``brian_preferences`` in the current directory.
32
33 The preference files are of the following form::
34
35 a.b.c = 1
36 # Comment line
37 [a]
38 b.d = 2
39 [a.b]
40 b.e = 3
41
42 This would set preferences ``a.b.c=1``, ``a.b.d=2`` and ``a.b.e=3``.
43
44 .. raw:: html
45
46 <details><summary>File setting all preferences to their default values</summary>
47
48 .. document_brian_prefs::
49 :nolinks:
50 :as_file:
51
52 .. raw:: html
53
54 </details>
55
56 List of preferences
57 -------------------
58 Brian itself defines the following preferences (including their default
59 values):
60
61 .. document_brian_prefs::