Skip to content

Commit

Permalink
Merge branch 'master' into Issue543
Browse files Browse the repository at this point in the history
  • Loading branch information
legouee committed Dec 8, 2017
2 parents 73772a2 + 86ba43b commit 47bab87
Show file tree
Hide file tree
Showing 36 changed files with 779 additions and 136 deletions.
21 changes: 15 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@ examples/tools/Results
examples/nineml_mechanisms
examples/*.dat
examples/*.svg

# Other
*.btr
*.log
/examples/LEMS_Sim_PyNN_NeuroML2_Export.xml
/pynnpg.sh
/cleanpynn.sh
/examples/Potjans2014/*.svg
/examples/Potjans2014/*.mod
/examples/Potjans2014/*.png
Expand All @@ -73,3 +67,18 @@ examples/*.svg
/examples/Potjans2014/*.so
/test/system/LEMS_Sim_Test0.xml
/test/system/Test0.net.nml
/examples/Potjans2014/*.spikes
/examples/Potjans2014/*.dat
/examples/Potjans2014/*_nrn.py
/examples/PyNN_NeuroML2_Export.net.nml
/examples/input.spikes
/examples/output.spikes
/examples/Potjans2014/clean.sh
/test/benchmarks/*.h5

# Other
*.btr
*.log
tmp
/pynnpg.sh
/cleanpynn.sh
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ dist: trusty
sudo: required
matrix:
include:
- python: 2.6
env: PYENV=py26
- python: 2.7
env: PYENV=py27
- python: 3.3
Expand All @@ -18,8 +16,8 @@ after_success:
- coveralls
cache:
directories:
- $HOME/nest-2.12.0
- $HOME/nrn-7.4
- $HOME/build/nest-2.12.0
- $HOME/build/nrn-7.4
- $HOME/nest-2.14.0
- $HOME/nrn-7.5
- $HOME/build/nest-2.14.0
- $HOME/build/nrn-7.5
- $HOME/.cache/pip
4 changes: 4 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ The following people have contributed to PyNN. Their affiliations at the time of
* Jannis Schücker [16]
* Maximilian Schmidt [16]
* Christian Roessert [13]
* Shailesh Appukuttan [1]
* Elodie Legouée [1]
* Joffrey Gonin [1]


1. Unité de Neuroscience, Information et Complexité, CNRS, Gif sur Yvette, France
2. Kirchhoff Institute for Physics, University of Heidelberg, Heidelberg, Germany
Expand Down
18 changes: 12 additions & 6 deletions ci/install_nest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ set -e # stop execution in case of errors

if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ] || [ "$TRAVIS_PYTHON_VERSION" == "3.5" ]; then
echo -e "\n========== Installing NEST ==========\n"
# Specify which version of NEST to install
#export NEST_VERSION="master"
export NEST_VERSION="2.12.0"
export NEST="nest-$NEST_VERSION"
export NEST_VERSION="2.14.0"

pip install cython==0.23.4
#wget https://github.com/nest/nest-simulator/archive/$NEST_VERSION.tar.gz -O $HOME/$NEST.tar.gz;
wget https://github.com/nest/nest-simulator/releases/download/v$NEST_VERSION/nest-$NEST_VERSION.tar.gz -O $HOME/$NEST.tar.gz

if [ "$NEST_VERSION" = "master" ]; then
export NEST="nest-simulator-$NEST_VERSION"
wget https://github.com/nest/nest-simulator/archive/$NEST_VERSION.tar.gz -O $HOME/$NEST.tar.gz;
else
export NEST="nest-$NEST_VERSION"
wget https://github.com/nest/nest-simulator/releases/download/v$NEST_VERSION/nest-$NEST_VERSION.tar.gz -O $HOME/$NEST.tar.gz
fi

pushd $HOME;
tar xzf $NEST.tar.gz;
ls;
Expand All @@ -18,8 +26,6 @@ if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ] || [ "$TRAVIS_PYTHON_VERSION" == "3.5"
mkdir -p $HOME/build/$NEST
pushd $HOME/build/$NEST
export VENV=`python -c "import sys; print(sys.prefix)"`;
echo "VENV = $VENV";
echo "PATH = $PATH";
ln -s /opt/python/2.7.13/lib/libpython2.7.so $VENV/lib/libpython2.7.so;
ln -s /opt/python/3.5.3/lib/libpython3.5m.so $VENV/lib/libpython3.5.so;
export PYTHON_INCLUDE_DIR=$VENV/include/python${TRAVIS_PYTHON_VERSION}
Expand Down
4 changes: 2 additions & 2 deletions ci/install_neuron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set -e # stop execution in case of errors

if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then
echo -e "\n========== Installing NEURON ==========\n"
export NRN_VERSION="nrn-7.4"
export NRN_VERSION="nrn-7.5"
if [ ! -f "$HOME/$NRN_VERSION/configure" ]; then
wget http://www.neuron.yale.edu/ftp/neuron/versions/v7.4/$NRN_VERSION.tar.gz -O $HOME/$NRN_VERSION.tar.gz;
wget http://www.neuron.yale.edu/ftp/neuron/versions/v7.5/$NRN_VERSION.tar.gz -O $HOME/$NRN_VERSION.tar.gz;
pushd $HOME;
tar xzf $NRN_VERSION.tar.gz;
popd;
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class MockNESTModule(mock.Mock):
# The short X.Y version.
version = '0.9'
# The full version, including alpha/beta/rc tags.
release = '0.9.1'
release = '0.9.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions doc/developers/contributing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ We try to stay fairly close to PEP8_. Please note in particular:
- some function/method names in PyNN use ``mixedCase``, but these will
gradually be deprecated and replaced with ``lower_case_with_underscores``.
Any new functions or methods should use the latter.
- we currently target versions 2.6, 2.7 and 3.3-3.6
- we currently target versions 2.7 and 3.3-3.6


Testing
Expand Down Expand Up @@ -194,7 +194,7 @@ last time:
:file:`test/unittests` and :file:`test/system` and running :command:`make doctest` in
:file:`doc`. You should do this on at least two Linux systems -- one a very
recent version and one at least a year old, and on at least one version of
Mac OS X. You should also do this with Python 2.6, 2.7 and 3.4, 3.5 or 3.6.
Mac OS X. You should also do this with Python 2.7 and 3.4, 3.5 or 3.6.
* do all the example scripts generate the correct output? Run the
:file:`run_all_examples.py` script in :file:`examples/tools` and then visually
check the :file:`.png` files generated in :file:`examples/tools/Results`. Again,
Expand Down
23 changes: 14 additions & 9 deletions doc/installation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ install and run PyNN on Windows, but this has not been tested.

Installing PyNN requires:

* Python (version 2.6, 2.7, 3.3-3.6)
* Python (version 2.7, 3.3-3.6)
* a recent version of the NumPy_ package
* the lazyarray_ package
* the Neo_ package (>= 0.5.0)
Expand All @@ -32,8 +32,8 @@ If you are running Debian or Ubuntu, there are :doc:`binary packages <download>`
available. If you would prefer to install manually, :doc:`download the latest
source distribution <download>`, then run the setup script, e.g.::

$ tar xzf PyNN-0.9.1.tar.gz
$ cd PyNN-0.9.1
$ tar xzf PyNN-0.9.2.tar.gz
$ cd PyNN-0.9.2
$ python setup.py install

This will install it to your Python :file:`site-packages` directory, and may
Expand All @@ -49,8 +49,13 @@ Test it using something like the following::
>>> sim.end()

(This assumes you have NEST installed).
If you get a warning "Unable to install NEST extensions. Certain models may not be available" then ensure the
program :command:`nest-config` is on your system PATH.

.. warning::

If you get a warning "Unable to install NEST extensions. Certain models may not be available" then ensure the
program :command:`nest-config` is on your system PATH.
If you still get this message even after adding the directory containing :command:`nest-config` to the PATH,
try ``pip uninstall PyNN``, then re-install with ``pip install --no-binary :all: PyNN``

With NEURON as the simulator, make sure you install NEURON *before* you install PyNN.
The PyNN installation will then compile PyNN-specific membrane mechanisms, which are loaded when importing the :mod:`neuron` module::
Expand All @@ -73,7 +78,7 @@ you will need to manually run :command:`nrnivmodl` in the :file:`pyNN/neuron/nmo
Installing NEURON
=================

Download the sources for the latest release of NEURON, in ``.tar.gz`` format, from `<http://www.neuron.yale.edu/neuron/download/getstd>`_.
Download the sources for NEURON 7.4 or 7.5, in ``.tar.gz`` format, from `<http://www.neuron.yale.edu/neuron/download/getstd>`_.
Also download Interviews from the same location.

Compile Interviews and NEURON according to the instructions given at `<http://www.neuron.yale.edu/neuron/static/download/compilestd_unix.html>`_,
Expand Down Expand Up @@ -113,8 +118,8 @@ If you run into problems, check out the `NEURON Forum`_.
Installing NEST and PyNEST
==========================

NEST 2.12 can be downloaded from `<http://www.nest-simulator.org/download/>`_.
Earlier versions of NEST will not work with this version of PyNN.
NEST 2.14 can be downloaded from `<http://www.nest-simulator.org/download/>`_.
Earlier versions of NEST may not work with this version of PyNN.
The full installation instructions are available in the file INSTALL, which you can find in the NEST source package,
or at `<http://www.nest-simulator.org/installation/>`_.

Expand All @@ -126,7 +131,7 @@ Now try it out::
-- N E S T --

Copyright (C) 2004 The NEST Initiative
Version 2.12.0 Mar 21 2016 21:29:37
Version 2.14.0 Nov 21 2017 11:05:28
...
>>> nest.Models()
(u'ac_generator', u'aeif_cond_alpha', u'aeif_cond_alpha_RK5', u'aeif_cond_alpha_multisynapse',
Expand Down
1 change: 1 addition & 0 deletions doc/release_notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Release notes
.. toctree::
:maxdepth: 1

releases/0.9.2.txt
releases/0.9.1.txt
releases/0.9.0.txt
releases/0.8.3.txt
Expand Down
2 changes: 2 additions & 0 deletions examples/Potjans2014/plotting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import os
import glob
Expand Down
121 changes: 121 additions & 0 deletions examples/Potjans2014/validation_microcircuit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
###################################################
### validation_microcircuit ###
### a modification of the microcircuit.py ###
###################################################

import os
import sys
from sim_params import simulator_params, system_params
sys.path.append(system_params['backend_path'])
sys.path.append(system_params['pyNN_path'])
from network_params import *
# import logging # TODO! Remove if it runs without this line
import pyNN
import time
from neo.io import PyNNTextIO
import plotting


# prepare simulation
#logging.basicConfig() # TODO! Remove if it runs without this line
simulator = simulator_params.keys()[0]
exec('import pyNN.%s as sim' % simulator)
sim.setup(**simulator_params[simulator])
import network

# Uncomment the two lines below when networkunit is installed
#import sciunit
#from networkunit.capabilities import ProducesSpikeTrains

# ===================SciUnit Interface=====================

# Uncomment the two lines below when networkunit is installed
#class Potjans2014Microcircuit( sciunit.Model,
# ProducesSpikeTrains ):
# Comment the line below when networkunit is installed
class Potjans2014Microcircuit():
'''
Use case:
'''
def __init__(self):
# prepare simulation
#exec('import pyNN.%s as sim' % simulator)
sim.setup(**simulator_params[simulator])

# The network takes a good amount of time so rather than make the user
# wait to produce some capability it is better to create the network
# when the capability is evoked
def create_network(self):
# create network
start_netw = time.time()
self.n = network.Network(sim)
self.n.setup(sim)
end_netw = time.time()
if sim.rank() == 0 :
print('Creating the network took %g s' % (end_netw - start_netw,))

def simulate(self):
# simulate
if sim.rank() == 0 :
print("Simulating...")
start_sim = time.time()
t = sim.run(simulator_params[simulator]['sim_duration'])
end_sim = time.time()
if sim.rank() == 0 :
print('Simulation took %g s' % (end_sim - start_sim,))

def write_spiketrains(self):
start_writing = time.time()
for layer in self.n.pops :
for pop in self.n.pops[layer] :
io = PyNNTextIO(filename=system_params['output_path'] \
+ "/spikes_" + layer \
+ '_' + pop \
+ '_' + str(sim.rank()) \
+ ".txt")
spikes = self.n.pops[layer][pop].get_data('spikes',
gather=False)
for segment in spikes.segments :
io.write_segment(segment)
if record_v :
io = PyNNTextIO(filename=system_params['output_path'] \
+ "/vm_" + layer \
+ '_' + pop \
+ '_' + str(sim.rank()) \
+ ".txt")
vm = self.n.pops[layer][pop].get_data('v',
gather=False)
for segment in vm.segments :
try :
io.write_segment(segment)
except AssertionError :
pass
end_writing = time.time()
print("Writing data took %g s" % (end_writing - start_writing,))

def plot_and_save(self):
if create_raster_plot and sim.rank() == 0 :
# Numbers of neurons from which spikes were recorded
n_rec = [[0] * n_pops_per_layer] * n_layers
for layer, i in layers.items() :
for pop, j in pops.items() :
if record_fraction:
n_rec[i][j] = round(N_full[layer][pop] * N_scaling * frac_record_spikes)
else:
n_rec[i][j] = n_record
plotting.show_raster_bars(raster_t_min, raster_t_max, n_rec,
frac_to_plot, system_params['output_path'] + '/')

def create_results_directory(self):
current_directory = os.getcwd()
build_path = current_directory + os.sep + "results"
if not os.path.exists("results"):
os.makedirs(build_path)

def produce_spiketrains(self):
self.create_network()
self.simulate()
self.create_results_directory()
self.write_spiketrains()
sim.end()
print ("The model " + self.__class__.__name__ + " produces_spiketrains.")
2 changes: 1 addition & 1 deletion pyNN/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
:license: CeCILL, see LICENSE for details.
"""

__version__ = '0.9.1'
__version__ = '0.9.2'
__all__ = ["common", "random", "nest", "neuron", "brian",
"recording", "errors", "space", "descriptions",
"standardmodels", "parameters", "core"]
9 changes: 9 additions & 0 deletions pyNN/brian/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import numpy
import brian
from pyNN.parameters import Sequence, simplify
from pyNN import errors
from . import simulator

mV = brian.mV
Expand Down Expand Up @@ -252,6 +253,7 @@ def __init__(self, n, equations, spike_times=None):
Note that `equations` is not used: it is simply for compatibility with
other NeuronGroup subclasses.
"""
self._check_spike_times(spike_times)
spiketimes = [(i, t) for i, seq in enumerate(spike_times) for t in seq.value]
brian.SpikeGeneratorGroup.__init__(self, n, spiketimes,
clock=simulator.state.network.clock)
Expand All @@ -267,9 +269,16 @@ def _set_spike_times(self, spike_times, mask=None):
existing_times = self._get_spike_times()
existing_times[mask] = spike_times
spike_times = existing_times
self._check_spike_times(spike_times)
values = [(i, t) for i, seq in enumerate(spike_times) for t in seq.value]
brian.SpikeGeneratorGroup.__init__(self, self.N, values, period=self.period)
spike_times = property(fget=_get_spike_times, fset=_set_spike_times)

def _check_spike_times(self, spike_times):
for seq in spike_times:
if numpy.any(seq.value[:-1] > seq.value[1:]):
raise errors.InvalidParameterValueError(
"Spike times given to SpikeSourceArray must be in increasing order")

def initialize(self):
pass
Loading

0 comments on commit 47bab87

Please sign in to comment.