File: _prefs.py

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 (66 lines) | stat: -rw-r--r-- 2,316 bytes parent folder | download | duplicates (2)
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
62
63
64
65
66
"""
Module declaring general code generation preferences.

Preferences
-----------
.. document_brian_prefs:: codegen
"""

from brian2.core.preferences import BrianPreference, prefs

from .codeobject import CodeObject

# Preferences
prefs.register_preferences(
    "codegen",
    "Code generation preferences",
    target=BrianPreference(
        default="auto",
        docs="""
        Default target for code generation.

        Can be a string, in which case it should be one of:

        * ``'auto'`` the default, automatically chose the best code generation
          target available.
        * ``'cython'``, uses the Cython package to generate C++ code. Needs a
          working installation of Cython and a C++ compiler.
        * ``'numpy'`` works on all platforms and doesn't need a C compiler but
          is often less efficient.

        Or it can be a ``CodeObject`` class.
        """,
        validator=lambda target: isinstance(target, str)
        or issubclass(target, CodeObject),
    ),
    string_expression_target=BrianPreference(
        default="numpy",
        docs="""
        Default target for the evaluation of string expressions (e.g. when
        indexing state variables). Should normally not be changed from the
        default numpy target, because the overhead of compiling code is not
        worth the speed gain for simple expressions.

        Accepts the same arguments as `codegen.target`, except for ``'auto'``
        """,
        validator=lambda target: isinstance(target, str)
        or issubclass(target, CodeObject),
    ),
    loop_invariant_optimisations=BrianPreference(
        default=True,
        docs="""
        Whether to pull out scalar expressions out of the statements, so that
        they are only evaluated once instead of once for every neuron/synapse/...
        Can be switched off, e.g. because it complicates the code (and the same
        optimisation is already performed by the compiler) or because the
        code generation target does not deal well with it. Defaults to ``True``.
        """,
    ),
    max_cache_dir_size=BrianPreference(
        default=1000,
        docs="""
        The size of a directory (in MB) with cached code for Cython that triggers
        a warning. Set to 0 to never get a warning.
        """,
    ),
)