File: preferences.rst

package info (click to toggle)
brian 2.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,872 kB
  • sloc: python: 51,820; cpp: 2,033; makefile: 108; sh: 72
file content (61 lines) | stat: -rw-r--r-- 1,745 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Preferences
===========

Brian has a system of global preferences that affect how certain objects
behave. These can be set either in scripts by using the `prefs` object
or in a file. Each preference looks like ``codegen.cpp.compiler``, i.e. dotted
names.

Accessing and setting preferences
---------------------------------
Preferences can be accessed and set either keyword-based or attribute-based.
The following are equivalent::

    prefs['codegen.cpp.compiler'] = 'unix'
    prefs.codegen.cpp.compiler = 'unix'

Using the attribute-based form can be particulary useful for interactive
work, e.g. in ipython, as it offers autocompletion and documentation.
In ipython, ``prefs.codegen.cpp?`` would display a docstring with all
the preferences available in the ``codegen.cpp`` category.

Preference files
----------------

Preferences are stored in a hierarchy of files, with the following order
(each step overrides the values in the previous step but no error is raised
if one is missing):

* The user default are stored in ``~/.brian/user_preferences`` (which works on
  Windows as well as Linux). The ``~`` symbol refers to the user directory.
* The file ``brian_preferences`` in the current directory.

The preference files are of the following form::

    a.b.c = 1
    # Comment line
    [a]
    b.d = 2
    [a.b]
    b.e = 3
    
This would set preferences ``a.b.c=1``, ``a.b.d=2`` and ``a.b.e=3``.

.. raw:: html

    <details><summary>File setting all preferences to their default values</summary>

.. document_brian_prefs::
    :nolinks:
    :as_file:

.. raw:: html

    </details>

List of preferences
-------------------
Brian itself defines the following preferences (including their default
values):

.. document_brian_prefs::