Skip to content

Commit bf36bd5

Browse files
authored
Merge pull request #775 from apdavison/spring-clean
Spring cleaning
2 parents 1b9694f + 8f21b66 commit bf36bd5

File tree

126 files changed

+1597
-1364
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+1597
-1364
lines changed

.github/workflows/full-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ jobs:
3232
run: |
3333
python -m pip install --upgrade pip
3434
python -m pip install pytest pytest-cov coveralls flake8
35-
python -m pip install mpi4py
3635
python -m pip install -r requirements.txt
36+
python -m pip install mpi4py matplotlib
3737
- name: Install Brian 2
3838
run: |
3939
python -m pip install brian2

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ your simulator, and are not restricted to the standard models.
3030
- Bug reports: https://github.com/NeuralEnsemble/PyNN/issues
3131

3232

33-
:copyright: Copyright 2006-2022 by the PyNN team, see AUTHORS.
33+
:copyright: Copyright 2006-2023 by the PyNN team, see AUTHORS.
3434
:license: CeCILL, see LICENSE for details.
3535

3636
.. image:: https://travis-ci.org/NeuralEnsemble/PyNN.png?branch=master

ci/install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -e # stop execution in case of errors
55
pip install -r requirements.txt
66
pip install coveralls
77
pip install pytest pytest-cov
8+
pip install matplotlib
89
source ci/install_brian.sh
910
source ci/install_nest.sh
1011
source ci/install_neuron.sh

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class MockNESTModule(mock.Mock):
6969
# General information about the project.
7070
project = u'PyNN'
7171
authors = u'the PyNN community'
72-
copyright = u'2006-2022, ' + authors
72+
copyright = u'2006-2023, ' + authors
7373

7474
# The version info for the project you're documenting, acts as replacement for
7575
# |version| and |release|, also used in various other places throughout the

pyNN/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
random
6666
space
6767
68-
:copyright: Copyright 2006-2022 by the PyNN team, see AUTHORS.
68+
:copyright: Copyright 2006-2023 by the PyNN team, see AUTHORS.
6969
:license: CeCILL, see LICENSE for details.
7070
"""
7171

pyNN/brian2/__init__.py

Lines changed: 39 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,49 @@
11
"""
22
Brian2 implementation of the PyNN API.
33
4-
:copyright: Copyright 2006-2016 by the PyNN team, see AUTHORS.
4+
:copyright: Copyright 2006-2023 by the PyNN team, see AUTHORS.
55
:license: CeCILL, see LICENSE for details.
66
"""
77

8-
import logging
9-
import brian2 # noqa: F401
10-
from pyNN import common, space # noqa: F401
11-
from pyNN.common.control import DEFAULT_MAX_DELAY, DEFAULT_TIMESTEP, DEFAULT_MIN_DELAY
12-
from pyNN.standardmodels import StandardCellType
13-
from pyNN.connectors import * # noqa: F401, F403
14-
from pyNN.connectors import FixedProbabilityConnector
15-
from pyNN.brian2 import simulator
16-
from pyNN.brian2.standardmodels.cells import * # noqa: F401, F403
17-
from pyNN.brian2.standardmodels.synapses import * # noqa: F401, F403
18-
from pyNN.brian2.standardmodels.synapses import StaticSynapse
19-
from pyNN.brian2.standardmodels.electrodes import * # noqa: F401, F403
20-
from pyNN.brian2.standardmodels.electrodes import update_currents
21-
from pyNN.brian2.standardmodels.receptors import ( # noqa: F401
22-
CondAlphaPostSynapticResponse, AlphaPSR,
23-
CondExpPostSynapticResponse, ExpPSR,
24-
CurrExpPostSynapticResponse)
25-
from pyNN.brian2.populations import Population, PopulationView, Assembly # noqa: F401
26-
from pyNN.brian2.projections import Projection
27-
from pyNN.recording import get_io
28-
29-
logger = logging.getLogger("PyNN")
8+
from .. import errors, random, space # noqa: F401
9+
from ..network import Network # noqa: F401
10+
from ..standardmodels import StandardCellType
11+
from ..random import NumpyRNG, GSLRNG, RandomDistribution # noqa: F401
12+
from ..connectors import * # noqa: F401, F403
13+
from .standardmodels.cells import * # noqa: F401, F403
14+
from .standardmodels.synapses import * # noqa: F401, F403
15+
from .standardmodels.electrodes import * # noqa: F401, F403
16+
from .standardmodels.receptors import ( # noqa: F401
17+
CondAlphaPostSynapticResponse,
18+
AlphaPSR,
19+
CondExpPostSynapticResponse,
20+
ExpPSR,
21+
CurrExpPostSynapticResponse,
22+
)
23+
from .populations import Population, PopulationView, Assembly # noqa: F401
24+
from .projections import Projection # noqa: F401
25+
from .control import ( # noqa: F401
26+
setup,
27+
end,
28+
run,
29+
run_until,
30+
run_for,
31+
reset,
32+
initialize,
33+
get_current_time,
34+
get_time_step,
35+
get_min_delay,
36+
get_max_delay,
37+
num_processes,
38+
rank,
39+
)
40+
from .procedural_api import create, connect, record, record_v, record_gsyn # noqa: F401
3041

3142

3243
def list_standard_models():
3344
"""Return a list of all the StandardCellType classes available for this simulator."""
34-
return [obj.__name__ for obj in globals().values()
35-
if isinstance(obj, type) and issubclass(obj, StandardCellType)]
36-
37-
38-
def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
39-
**extra_params):
40-
"""
41-
Should be called at the very beginning of a script.
42-
extra_params contains any keyword arguments that are required by a given
43-
simulator but not by others.
44-
"""
45-
46-
max_delay = extra_params.get('max_delay', DEFAULT_MAX_DELAY)
47-
common.setup(timestep, min_delay, **extra_params)
48-
simulator.state.clear()
49-
simulator.state.dt = timestep # move to common.setup?
50-
simulator.state.min_delay = min_delay
51-
simulator.state.max_delay = max_delay
52-
simulator.state.mpi_rank = 0
53-
simulator.state.num_processes = 1
54-
55-
simulator.state.network.add(
56-
brian2.NetworkOperation(update_currents, when="start", clock=simulator.state.network.clock)
57-
)
58-
return rank()
59-
60-
61-
def end(compatible_output=True):
62-
"""Do any necessary cleaning up before exiting."""
63-
for (population, variables, filename) in simulator.state.write_on_end:
64-
io = get_io(filename)
65-
population.write_data(io, variables)
66-
simulator.state.write_on_end = []
67-
# should have common implementation of end()
68-
69-
70-
run, run_until = common.build_run(simulator)
71-
run_for = run
72-
73-
reset = common.build_reset(simulator)
74-
75-
initialize = common.initialize
76-
77-
get_current_time, get_time_step, get_min_delay, get_max_delay, \
78-
num_processes, rank = common.build_state_queries(simulator)
79-
80-
create = common.build_create(Population)
81-
82-
connect = common.build_connect(Projection, FixedProbabilityConnector, StaticSynapse)
83-
84-
85-
record = common.build_record(simulator)
86-
87-
88-
def record_v(source, filename): return record(['v'], source, filename)
89-
90-
91-
def record_gsyn(source, filename): return record(['gsyn_exc', 'gsyn_inh'], source, filename)
45+
return [
46+
obj.__name__
47+
for obj in globals().values()
48+
if isinstance(obj, type) and issubclass(obj, StandardCellType)
49+
]

pyNN/brian2/cells.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
"""
22
Definition of cell classes for the brian2 module.
33
4-
:copyright: Copyright 2006-2016 by the PyNN team, see AUTHORS.
4+
:copyright: Copyright 2006-2023 by the PyNN team, see AUTHORS.
55
:license: CeCILL, see LICENSE for details.
66
77
"""
88

9-
9+
from functools import reduce
1010
import numpy as np
1111
import brian2
12-
from functools import reduce
13-
from pyNN.parameters import Sequence, simplify
14-
from pyNN.core import is_listlike
15-
from pyNN import errors
16-
from pyNN.brian2 import simulator
12+
13+
from ..parameters import Sequence, simplify
14+
from ..core import is_listlike
15+
from .. import errors
16+
from . import simulator
1717

1818
mV = brian2.mV
1919
ms = brian2.ms

pyNN/brian2/control.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""
2+
Brian 2 implementation of simulation control functions
3+
4+
:copyright: Copyright 2006-2023 by the PyNN team, see AUTHORS.
5+
:license: CeCILL, see LICENSE for details.
6+
"""
7+
8+
import brian2
9+
from ..common.control import DEFAULT_MAX_DELAY, DEFAULT_TIMESTEP, DEFAULT_MIN_DELAY
10+
from .. import common
11+
from ..recording import get_io
12+
from . import simulator
13+
from .standardmodels.electrodes import update_currents
14+
15+
16+
def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
17+
**extra_params):
18+
"""
19+
Should be called at the very beginning of a script.
20+
extra_params contains any keyword arguments that are required by a given
21+
simulator but not by others.
22+
"""
23+
24+
max_delay = extra_params.get('max_delay', DEFAULT_MAX_DELAY)
25+
common.setup(timestep, min_delay, **extra_params)
26+
simulator.state.clear()
27+
simulator.state.dt = timestep # move to common.setup?
28+
simulator.state.min_delay = min_delay
29+
simulator.state.max_delay = max_delay
30+
simulator.state.mpi_rank = 0
31+
simulator.state.num_processes = 1
32+
33+
simulator.state.network.add(
34+
brian2.NetworkOperation(update_currents, when="start", clock=simulator.state.network.clock)
35+
)
36+
return rank()
37+
38+
39+
def end(compatible_output=True):
40+
"""Do any necessary cleaning up before exiting."""
41+
for (population, variables, filename) in simulator.state.write_on_end:
42+
io = get_io(filename)
43+
population.write_data(io, variables)
44+
simulator.state.write_on_end = []
45+
# should have common implementation of end()
46+
47+
48+
run, run_until = common.build_run(simulator)
49+
run_for = run
50+
51+
reset = common.build_reset(simulator)
52+
53+
initialize = common.initialize
54+
55+
get_current_time, get_time_step, get_min_delay, get_max_delay, \
56+
num_processes, rank = common.build_state_queries(simulator)

pyNN/brian2/populations.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
"""
2+
Brian 2 implementation of Population, PopulationView and Assembly.
23
4+
:copyright: Copyright 2006-2023 by the PyNN team, see AUTHORS.
5+
:license: CeCILL, see LICENSE for details.
36
"""
47

58
from collections import defaultdict
69
import numpy as np
7-
from pyNN import common
8-
from pyNN.standardmodels import StandardCellType
9-
from pyNN.parameters import ArrayParameter, ParameterSpace, simplify, LazyArray
10+
from .. import common
11+
from ..standardmodels import StandardCellType
12+
from ..parameters import ArrayParameter, ParameterSpace, simplify, LazyArray
1013
from . import simulator
1114
from .recording import Recorder
1215
import brian2

pyNN/brian2/procedural_api.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
Brian 2 implementation of the "procedural" API
3+
4+
:copyright: Copyright 2006-2023 by the PyNN team, see AUTHORS.
5+
:license: CeCILL, see LICENSE for details.
6+
"""
7+
8+
from .. import common
9+
from ..connectors import FixedProbabilityConnector
10+
from .populations import Population
11+
from .projections import Projection
12+
from .standardmodels.synapses import StaticSynapse
13+
from . import simulator
14+
15+
16+
create = common.build_create(Population)
17+
18+
19+
connect = common.build_connect(Projection, FixedProbabilityConnector, StaticSynapse)
20+
21+
22+
record = common.build_record(simulator)
23+
24+
25+
def record_v(source, filename):
26+
return record(['v'], source, filename)
27+
28+
29+
def record_gsyn(source, filename):
30+
return record(['gsyn_exc', 'gsyn_inh'], source, filename)

0 commit comments

Comments
 (0)