| 1 |
""" |
| 2 |
A dummy package to allow wildcard import from brian2 without also importing |
| 3 |
the pylab (numpy + matplotlib) namespace. |
| 4 |
|
| 5 |
Usage: ``from brian2.only import *`` |
| 6 |
|
| 7 |
""" |
| 8 |
|
| 9 |
# To minimize the problems with imports, import the packages in a sensible |
| 10 |
# order |
| 11 |
|
| 12 |
# isort:skip_file |
| 13 |
# flake8: noqa |
| 14 |
|
| 15 |
# The units and utils package does not depend on any other Brian package and |
| 16 |
# should be imported first |
| 17 |
|
| 18 |
from brian2.units import * |
| 19 |
from brian2.utils import * |
| 20 |
from brian2.core.tracking import * |
| 21 |
from brian2.core.names import * |
| 22 |
from brian2.core.spikesource import * |
| 23 |
|
| 24 |
# The following packages only depend on something in the above set |
| 25 |
from brian2.core.variables import linked_var |
| 26 |
from brian2.core.functions import * |
| 27 |
from brian2.core.preferences import * |
| 28 |
from brian2.core.clocks import * |
| 29 |
from brian2.equations import * |
| 30 |
|
| 31 |
# The base class only depends on the above sets |
| 32 |
from brian2.core.base import * |
| 33 |
|
| 34 |
# The rest... |
| 35 |
from brian2.core.network import * |
| 36 |
from brian2.core.magic import * |
| 37 |
from brian2.core.operations import * |
| 38 |
from brian2.stateupdaters import * |
| 39 |
from brian2.codegen import * |
| 40 |
from brian2.core.namespace import * |
| 41 |
from brian2.groups import * |
| 42 |
from brian2.groups.subgroup import * |
| 43 |
from brian2.synapses import * |
| 44 |
from brian2.monitors import * |
| 45 |
from brian2.importexport import * |
| 46 |
from brian2.input import * |
| 47 |
from brian2.spatialneuron import * |
| 48 |
from brian2.devices import set_device, get_device, device, all_devices, seed |
| 49 |
import brian2.devices.cpp_standalone as _cpp_standalone |
| 50 |
|
| 51 |
# preferences |
| 52 |
import brian2.core.core_preferences as _core_preferences |
| 53 |
|
| 54 |
prefs.load_preferences() |
| 55 |
prefs.do_validation() |
| 56 |
|
| 57 |
prefs._backup() |
| 58 |
|
| 59 |
set_device(all_devices["runtime"]) |
| 60 |
|
| 61 |
|
| 62 |
def restore_initial_state(): |
| 63 |
""" |
| 64 |
Restores internal Brian variables to the state they are in when Brian is imported |
| 65 |
|
| 66 |
Resets ``defaultclock.dt = 0.1*ms``, |
| 67 |
`BrianGlobalPreferences._restore` preferences, and set |
| 68 |
`BrianObject._scope_current_key` back to 0. |
| 69 |
""" |
| 70 |
import gc |
| 71 |
|
| 72 |
prefs._restore() |
| 73 |
BrianObject._scope_current_key = 0 |
| 74 |
defaultclock.dt = 0.1 * ms |
| 75 |
gc.collect() |
| 76 |
|
| 77 |
|
| 78 |
# make the test suite available via brian2.test() |
| 79 |
from brian2.tests import run as test |
| 80 |
|
| 81 |
from brian2.units import __all__ as _all_units |
| 82 |
|
| 83 |
__all__ = [ |
| 84 |
"get_logger", |
| 85 |
"BrianLogger", |
| 86 |
"std_silent", |
| 87 |
"Trackable", |
| 88 |
"Nameable", |
| 89 |
"SpikeSource", |
| 90 |
"linked_var", |
| 91 |
"DEFAULT_FUNCTIONS", |
| 92 |
"Function", |
| 93 |
"implementation", |
| 94 |
"declare_types", |
| 95 |
"PreferenceError", |
| 96 |
"BrianPreference", |
| 97 |
"prefs", |
| 98 |
"brian_prefs", |
| 99 |
"Clock", |
| 100 |
"EventClock", |
| 101 |
"defaultclock", |
| 102 |
"Equations", |
| 103 |
"Expression", |
| 104 |
"Statements", |
| 105 |
"BrianObject", |
| 106 |
"BrianObjectException", |
| 107 |
"Network", |
| 108 |
"profiling_summary", |
| 109 |
"scheduling_summary", |
| 110 |
"MagicNetwork", |
| 111 |
"magic_network", |
| 112 |
"MagicError", |
| 113 |
"run", |
| 114 |
"stop", |
| 115 |
"collect", |
| 116 |
"store", |
| 117 |
"restore", |
| 118 |
"start_scope", |
| 119 |
"NetworkOperation", |
| 120 |
"network_operation", |
| 121 |
"StateUpdateMethod", |
| 122 |
"linear", |
| 123 |
"exact", |
| 124 |
"independent", |
| 125 |
"milstein", |
| 126 |
"heun", |
| 127 |
"euler", |
| 128 |
"rk2", |
| 129 |
"rk4", |
| 130 |
"ExplicitStateUpdater", |
| 131 |
"exponential_euler", |
| 132 |
"gsl_rk2", |
| 133 |
"gsl_rk4", |
| 134 |
"gsl_rkf45", |
| 135 |
"gsl_rkck", |
| 136 |
"gsl_rk8pd", |
| 137 |
"NumpyCodeObject", |
| 138 |
"CythonCodeObject", |
| 139 |
"get_local_namespace", |
| 140 |
"DEFAULT_FUNCTIONS", |
| 141 |
"DEFAULT_UNITS", |
| 142 |
"DEFAULT_CONSTANTS", |
| 143 |
"CodeRunner", |
| 144 |
"Group", |
| 145 |
"VariableOwner", |
| 146 |
"NeuronGroup", |
| 147 |
"Subgroup", |
| 148 |
"Synapses", |
| 149 |
"SpikeMonitor", |
| 150 |
"EventMonitor", |
| 151 |
"StateMonitor", |
| 152 |
"PopulationRateMonitor", |
| 153 |
"ImportExport", |
| 154 |
"BinomialFunction", |
| 155 |
"PoissonGroup", |
| 156 |
"PoissonInput", |
| 157 |
"SpikeGeneratorGroup", |
| 158 |
"TimedArray", |
| 159 |
"Morphology", |
| 160 |
"Soma", |
| 161 |
"Cylinder", |
| 162 |
"Section", |
| 163 |
"SpatialNeuron", |
| 164 |
"set_device", |
| 165 |
"get_device", |
| 166 |
"device", |
| 167 |
"all_devices", |
| 168 |
"seed", |
| 169 |
"restore_initial_state", |
| 170 |
"test", |
| 171 |
] |
| 172 |
__all__.extend(_all_units) |