File: core_preferences.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 (72 lines) | stat: -rw-r--r-- 2,202 bytes parent folder | download
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
67
68
69
70
71
72
"""
Definitions, documentation, default values and validation functions for core
Brian preferences.
"""

from numpy import float32, float64, int32

from brian2.core.preferences import BrianPreference, prefs

__all__ = []


def dtype_repr(dtype):
    return dtype.__name__


def default_float_dtype_validator(dtype):
    return dtype in [float32, float64]


prefs.register_preferences(
    "core",
    "Core Brian preferences",
    default_float_dtype=BrianPreference(
        default=float64,
        docs="""
        Default dtype for all arrays of scalars (state variables, weights, etc.).
        """,
        representor=dtype_repr,
        validator=default_float_dtype_validator,
    ),
    default_integer_dtype=BrianPreference(
        default=int32,
        docs="""
        Default dtype for all arrays of integer scalars.
        """,
        representor=dtype_repr,
    ),
    outdated_dependency_error=BrianPreference(
        default=True,
        docs="""
        Whether to raise an error for outdated dependencies (``True``) or just
        a warning (``False``).
        """,
    ),
    stop_on_keyboard_interrupt=BrianPreference(
        default=True,
        docs="""
        Whether to "gracefully" stop a simulation after pressing Ctrl+C (defaults to
        ``True``). Note that pressing Ctrl+C a second time will force the usual
        interruption mechanism.
        """,
    ),
)

prefs.register_preferences(
    "legacy",
    "Preferences to enable legacy behaviour",
    refractory_timing=BrianPreference(
        default=False,
        docs="""
        Whether to use the semantics for checking the refractoriness condition
        that were in place up until (including) version 2.1.2. In that
        implementation, refractory periods that were multiples of dt could lead
        to a varying number of refractory timesteps due to the nature of
        floating point comparisons). This preference is only provided for exact
        reproducibility of previously obtained results, new simulations should
        use the improved mechanism which uses a more robust mechanism to
        convert refractoriness into timesteps. Defaults to ``False``.
        """,
    ),
)