Skip to content

Commit

Permalink
v2.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jougs committed Sep 30, 2015
1 parent 8d9c02e commit 3ad9cad
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 90 deletions.
4 changes: 2 additions & 2 deletions configure.ac.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#

AC_PREREQ(2.52)
AC_INIT([nest], [2.4.1], [[email protected]])
AC_INIT([nest], [2.4.2], [[email protected]])

# Prevent automatic rebuilding of Makefile.ins and configure if their
# content or timestamp changes. Not doing this lead to failing builds
Expand All @@ -20,7 +20,7 @@ AM_MAINTAINER_MODE([disable])
# releasetools/buildnest
SLI_MAJOR=2
SLI_MINOR=4
SLI_PATCHLEVEL=1
SLI_PATCHLEVEL=2

SLI_PRGNAME="nest-$SLI_MAJOR.$SLI_MINOR.$SLI_PATCHLEVEL"
SLI_VERSION=$SLI_MAJOR.$SLI_MINOR.$SLI_PATCHLEVEL
Expand Down
2 changes: 1 addition & 1 deletion examples/nest/music/minimalmusicsetup_receivenest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

n = nest.Create ('iaf_neuron')

nest.Connect (meip, n, { 'weight' : 750.0 })
nest.Connect (meip, n, 'one_to_one', { 'weight' : 750.0 })

vm = nest.Create ('voltmeter')
nest.SetStatus (vm, { 'to_memory' : False, 'to_screen' : True })
Expand Down
4 changes: 2 additions & 2 deletions examples/nest/music/minimalmusicsetup_sendnest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

n = nest.Create ('iaf_neuron')

nest.Connect (sg, n, [750.0], [1.0])
nest.Connect (sg, n, 'one_to_one', { 'weight': 750.0, 'delay': 1.0 })

vm = nest.Create ('voltmeter')
nest.SetStatus (vm, { 'to_memory' : False, 'to_screen' : True })
Expand All @@ -45,6 +45,6 @@
meop = nest.Create ('music_event_out_proxy')
nest.SetStatus (meop, { 'port_name' : 'spikes_out' })

nest.Connect (sg, meop, { 'music_channel' : 0 })
nest.Connect (sg, meop, 'one_to_one', { 'music_channel' : 0 })

nest.Simulate (10)
9 changes: 7 additions & 2 deletions nestkernel/conn_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ nest::ConnBuilder::ConnBuilder(Network& net,

DictionaryDatum syn_defaults = net_.get_connector_defaults(synapse_model_);

#ifdef HAVE_MUSIC
// We allow music_channel as alias for receptor_type during connection setup
(*syn_defaults)[names::music_channel] = 0;
#endif

// If neither weight or delay are given in the dict, we handle this
// separately. Important for hom_wd synapses, on which weight and delay
// cannot be set.
Expand Down Expand Up @@ -135,7 +140,7 @@ nest::ConnBuilder::ConnBuilder(Network& net,
it != synapse_params_.end();
++it )
{
if ( it->first == names::receptor_type )
if ( it->first == names::receptor_type || it->first == names::music_channel )
(*param_dicts_[t])[it->first] = Token(new IntegerDatum(0));
else
(*param_dicts_[t])[it->first] = Token(new DoubleDatum(0.0));
Expand Down Expand Up @@ -261,7 +266,7 @@ void nest::ConnBuilder::single_connect_(index sgid, index tgid,
it != synapse_params_.end();
++it )
{
if ( it->first == names::receptor_type )
if ( it->first == names::receptor_type || it->first == names::music_channel )
{
try
{
Expand Down
134 changes: 69 additions & 65 deletions pynest/nest/hl_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,51 @@ def _warning(msg, cat=UserWarning, fname='', lineno=-1):

# These flags are used to print deprecation warnings only once. The
# corresponding functions will be removed in the 2.6 release of NEST.
_deprecation_warning = {'FindConnections': True,
'OneToOneConnect': True,
'ConvergentConnect': True,
'RandomConvergentConnect': True,
'DivergentConnect': True,
'RandomDivergentConnect': True,
'BackwardCompatibilityConnect': True}
_deprecation_warning = {'BackwardCompatibilityConnect': True}

def show_deprecation_warning(func_name, text=None):
if _deprecation_warning[func_name]:
if text is None:
text = "".join(["{} is deprecated and will be removed in NEST 2.6.".format(func_name),
"Please use Connect from now on. For details, see the documentation at:\n",
"http://nest-initiative.org/Connection_Management"])
warnings.warn(text)
_deprecation_warning[func_name] = False

def deprecated(func, text=None):
"""Decorator for deprecated functions. Shows a warning and calls the original function."""
_deprecation_warning[func.__name__] = True
def new_func(*args, **kwargs):
show_deprecation_warning(func.__name__, text=text)
return func(*args, **kwargs)
new_func.__name__ = func.__name__
new_func.__doc__ = func.__doc__
new_func.__dict__.update(func.__dict__)
return new_func

# -------------------- Helper functions

def get_unistring_type():
import sys
if sys.version_info[0] < 3:
return basestring
return str

uni_str = get_unistring_type()

def is_literal(obj):
"""
Check whether obj is a "literal": a unicode string or SLI literal
"""
return isinstance(obj, (uni_str, SLILiteral))

def is_string(obj):
"""
Check whether obj is a "literal": a unicode string or SLI literal
"""
return isinstance(obj, uni_str)


def set_debug(dbg=True):
"""
Set the debug flag of the high-level API.
Expand Down Expand Up @@ -374,7 +409,7 @@ def GetKernelStatus(keys=None):

if keys is None:
return d
elif isinstance(keys, (str, SLILiteral)):
elif is_literal(keys):
return d[keys]
elif is_iterable(keys):
return tuple(d[k] for k in keys)
Expand Down Expand Up @@ -497,7 +532,7 @@ def SetDefaults(model, params, val=None):
"""

if val is not None:
if isinstance(params, (str, SLILiteral)):
if is_literal(params):
params = {params: val}

sps(params)
Expand All @@ -518,7 +553,7 @@ def GetDefaults(model, keys=None):

if keys is None:
cmd = "/{0} GetDefaults".format(model)
elif isinstance(keys, (str, SLILiteral)):
elif is_literal(keys):
cmd = '/{0} GetDefaults /{1} get'.format(model, keys)
elif is_iterable(keys):
keys_str = " ".join("/{0}".format(x) for x in keys)
Expand Down Expand Up @@ -599,12 +634,11 @@ def SetStatus(nodes, params, val=None):
if len(nodes) == 0:
return

if val is not None:
if isinstance(params, (str, SLILiteral)):
if is_iterable(val) and not isinstance(val, (str, dict)):
params = [{params: x} for x in val]
else:
params = {params: val}
if val is not None and is_literal(params):
if is_iterable(val) and not isinstance(val, (uni_str, dict)):
params = [{params: x} for x in val]
else:
params = {params: val}

params = broadcast(params, len(nodes), (dict,), "params")
if len(nodes) != len(params):
Expand Down Expand Up @@ -638,7 +672,7 @@ def GetStatus(nodes, keys=None):

if keys is None:
cmd = '{ GetStatus } Map'
elif isinstance(keys, (str, SLILiteral)):
elif is_literal(keys):
cmd = '{{ GetStatus /{0} get }} Map'.format(keys)
elif is_iterable(keys):
keys_str = " ".join("/{0}".format(x) for x in keys)
Expand Down Expand Up @@ -675,6 +709,7 @@ def GetLID(gid) :
# -------------------- Functions for connection handling

@check_stack
@deprecated
def FindConnections(source, target=None, synapse_model=None, synapse_type=None):
"""
Return an array of identifiers for connections that match the
Expand All @@ -690,12 +725,6 @@ def FindConnections(source, target=None, synapse_model=None, synapse_type=None):
Note: synapse_type is alias for synapse_model for backward compatibility.
"""

if _deprecation_warning["FindConnections"]:
warnings.warn("FindConnections is deprecated and will be removed in NEST 2.6. "
"Please use GetConnections from now on. For details, see the documentation "
"at http://nest-initiative.org/Connection_Management.")
_deprecation_warning["FindConnections"] = False

if synapse_model is not None and synapse_type is not None:
raise NESTError("'synapse_type' is alias for 'synapse_model' and cannot be used together with 'synapse_model'.")

Expand All @@ -705,15 +734,15 @@ def FindConnections(source, target=None, synapse_model=None, synapse_type=None):
if target is None and synapse_model is None:
params = [{"source": s} for s in source]
elif target is None and synapse_model is not None:
synapse_model = broadcast(synapse_model, len(source), (str,), "synapse_model")
synapse_model = broadcast(synapse_model, len(source), (uni_str,), "synapse_model")
params = [{"source": s, "synapse_model": syn}
for s, syn in zip(source, synapse_model)]
elif target is not None and synapse_model is None:
target = broadcast(target, len(source), (int,), "target")
params = [{"source": s, "target": t} for s, t in zip(source, target)]
else: # target is not None and synapse_model is not None
target = broadcast(target, len(source), (int,), "target")
synapse_model = broadcast(synapse_model, len(source), (str,), "synapse_model")
synapse_model = broadcast(synapse_model, len(source), (uni_str,), "synapse_model")
params = [{"source": s, "target": t, "synapse_model": syn}
for s, t, syn in zip(source, target, synapse_model)]

Expand Down Expand Up @@ -785,6 +814,7 @@ def GetConnections(source=None, target=None, synapse_model=None):


@check_stack
@deprecated
def OneToOneConnect(pre, post, params=None, delay=None, model="static_synapse"):
"""
Make one-to-one connections of type model between the nodes in
Expand All @@ -796,12 +826,6 @@ def OneToOneConnect(pre, post, params=None, delay=None, model="static_synapse"):
as list of floats.
"""

if _deprecation_warning["OneToOneConnect"]:
warnings.warn("OneToOneConnect is deprecated and will be removed in NEST 2.6. "
"Please use Connect from now on. For details, see the documentation "
"at http://nest-initiative.org/Connection_Management.")
_deprecation_warning["OneToOneConnect"] = False

if len(pre) != len(post):
raise NESTError("pre and post have to be the same length")

Expand Down Expand Up @@ -845,6 +869,7 @@ def OneToOneConnect(pre, post, params=None, delay=None, model="static_synapse"):


@check_stack
@deprecated
def ConvergentConnect(pre, post, weight=None, delay=None, model="static_synapse"):
"""
Connect all neurons in pre to each neuron in post. pre and post
Expand All @@ -853,12 +878,6 @@ def ConvergentConnect(pre, post, weight=None, delay=None, model="static_synapse"
floats.
"""

if _deprecation_warning["ConvergentConnect"]:
warnings.warn("ConvergentConnect is deprecated and will be removed in NEST 2.6. "
"Please use Connect from now on. For details, see the documentation "
"at http://nest-initiative.org/Connection_Management.")
_deprecation_warning["ConvergentConnect"] = False

if weight is None and delay is None:
for d in post :
sps(pre)
Expand All @@ -885,6 +904,7 @@ def ConvergentConnect(pre, post, weight=None, delay=None, model="static_synapse"


@check_stack
@deprecated
def RandomConvergentConnect(pre, post, n, weight=None, delay=None, model="static_synapse", options=None):
"""
Connect n randomly selected neurons from pre to each neuron in
Expand All @@ -895,12 +915,6 @@ def RandomConvergentConnect(pre, post, n, weight=None, delay=None, model="static
allow_multapses.
"""

if _deprecation_warning["RandomConvergentConnect"]:
warnings.warn("RandomConvergentConnect is deprecated and will be removed in NEST 2.6. "
"Please use Connect from now on. For details, see the documentation "
"at http://nest-initiative.org/Connection_Management.")
_deprecation_warning["RandomConvergentConnect"] = False

if not isinstance(n, int):
raise TypeError("number of neurons n should be an integer")

Expand Down Expand Up @@ -944,6 +958,7 @@ def RandomConvergentConnect(pre, post, n, weight=None, delay=None, model="static


@check_stack
@deprecated
def DivergentConnect(pre, post, weight=None, delay=None, model="static_synapse"):
"""
Connect each neuron in pre to all neurons in post. pre and post
Expand All @@ -952,12 +967,6 @@ def DivergentConnect(pre, post, weight=None, delay=None, model="static_synapse")
floats.
"""

if _deprecation_warning["DivergentConnect"]:
warnings.warn("DivergentConnect is deprecated and will be removed in NEST 2.6. "
"Please use Connect from now on. For details, see the documentation "
"at http://nest-initiative.org/Connection_Management.")
_deprecation_warning["DivergentConnect"] = False

if weight is None and delay is None:
for s in pre :
sps(s)
Expand Down Expand Up @@ -1062,13 +1071,13 @@ def Connect(pre, post, conn_spec=None, syn_spec=None, model=None):
Note: model is alias for syn_spec for backward compatibility.
"""


if _deprecation_warning["BackwardCompatibilityConnect"] and model is not None:
warnings.warn("The argument 'model' is there for backward compatibility with the old "
"Connect function and will be removed in NEST 2.6. Please change the name "
"of the keyword argument from 'model' to 'syn_spec'. For details, see the "
"documentation at http://nest-initiative.org/Connection_Management.")
_deprecation_warning["BackwardCompatibilityConnect"] = False
if model is not None:
deprecation_text = "".join(["The argument 'model' is there for backward compatibility with the old ",
"Connect function and will be removed in NEST 2.6. Please change the name ",
"of the keyword argument from 'model' to 'syn_spec'. For details, see the ",
"documentation at:\nhttp://nest-initiative.org/Connection_Management"])
show_deprecation_warning("BackwardCompatibilityConnect",
text=deprecation_text)

if model is not None and syn_spec is not None:
raise NESTError("'model' is an alias for 'syn_spec' and cannot be used together with 'syn_spec'.")
Expand All @@ -1078,7 +1087,7 @@ def Connect(pre, post, conn_spec=None, syn_spec=None, model=None):

if conn_spec is not None:
sps(conn_spec)
if isinstance(conn_spec, str):
if is_string(conn_spec):
sr("cvlit")
else:
sr('/Connect /conn_spec GetOption')
Expand All @@ -1088,7 +1097,7 @@ def Connect(pre, post, conn_spec=None, syn_spec=None, model=None):

if syn_spec is not None:
sps(syn_spec)
if isinstance(syn_spec, str):
if is_string(syn_spec):
sr("cvlit")

sr('Connect')
Expand Down Expand Up @@ -1151,6 +1160,7 @@ def DataConnect(pre, params=None, model="static_synapse"):


@check_stack
@deprecated
def RandomDivergentConnect(pre, post, n, weight=None, delay=None, model="static_synapse", options=None):
"""
Connect each neuron in pre to n randomly selected neurons from
Expand All @@ -1161,12 +1171,6 @@ def RandomDivergentConnect(pre, post, n, weight=None, delay=None, model="static_
allow_multapses.
"""

if _deprecation_warning["RandomDivergentConnect"]:
warnings.warn("RandomDivergentConnect is deprecated and will be removed in NEST 2.6. "
"Please use Connect from now on. For details, see the documentation "
"at http://nest-initiative.org/Connection_Management.")
_deprecation_warning["RandomDivergentConnect"] = False

if not isinstance(n, int):
raise TypeError("number of neurons n should be an integer")

Expand Down Expand Up @@ -1452,7 +1456,7 @@ def LayoutNetwork(model, dim, label=None, params=None):
for the neurons in the subnetwork.
"""

if isinstance(model, (str, SLILiteral)):
if is_literal(model):
sps(dim)
sr('/%s exch LayoutNetwork' % model)
if label is not None:
Expand Down
5 changes: 3 additions & 2 deletions pynest/pynestkernel.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,13 @@ cdef class NESTEngine(object):
cdef string modulepath_str = modulepath.encode()

cdef char* arg0 = "pynest\0"
cdef char** argv_bytes = <char**> malloc(argc * sizeof(char*))
cdef char** argv_bytes = <char**> malloc((argc+1) * sizeof(char*))

if argv_bytes is NULL:
raise NESTError("couldn't allocate argv_bytes")

argv_bytes[0] = arg0
argv_bytes[0] = arg0
argv_bytes[argc] = NULL

try:
for i in range(1, argc):
Expand Down
Loading

0 comments on commit 3ad9cad

Please sign in to comment.