diff --git a/configure.ac.in b/configure.ac.in index c5a1ded6b3..671713dd30 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -6,7 +6,7 @@ # AC_PREREQ(2.52) -AC_INIT([nest], [2.4.1], [nest_user@nest-initiative.org]) +AC_INIT([nest], [2.4.2], [nest_user@nest-initiative.org]) # Prevent automatic rebuilding of Makefile.ins and configure if their # content or timestamp changes. Not doing this lead to failing builds @@ -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 diff --git a/examples/nest/music/minimalmusicsetup_receivenest.py b/examples/nest/music/minimalmusicsetup_receivenest.py index b4f8ae1cc9..198197ebdf 100755 --- a/examples/nest/music/minimalmusicsetup_receivenest.py +++ b/examples/nest/music/minimalmusicsetup_receivenest.py @@ -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 }) diff --git a/examples/nest/music/minimalmusicsetup_sendnest.py b/examples/nest/music/minimalmusicsetup_sendnest.py index 3f394eefe7..0d9c39cb37 100755 --- a/examples/nest/music/minimalmusicsetup_sendnest.py +++ b/examples/nest/music/minimalmusicsetup_sendnest.py @@ -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 }) @@ -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) diff --git a/nestkernel/conn_builder.cpp b/nestkernel/conn_builder.cpp index 510b1f76a4..32cbf1fae0 100644 --- a/nestkernel/conn_builder.cpp +++ b/nestkernel/conn_builder.cpp @@ -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. @@ -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)); @@ -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 { diff --git a/pynest/nest/hl_api.py b/pynest/nest/hl_api.py index b7087c8d07..55b02ad6f2 100644 --- a/pynest/nest/hl_api.py +++ b/pynest/nest/hl_api.py @@ -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. @@ -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) @@ -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) @@ -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) @@ -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): @@ -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) @@ -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 @@ -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'.") @@ -705,7 +734,7 @@ 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: @@ -713,7 +742,7 @@ def FindConnections(source, target=None, synapse_model=None, synapse_type=None): 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)] @@ -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 @@ -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") @@ -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 @@ -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) @@ -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 @@ -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") @@ -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 @@ -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) @@ -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'.") @@ -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') @@ -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') @@ -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 @@ -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") @@ -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: diff --git a/pynest/pynestkernel.pyx b/pynest/pynestkernel.pyx index 02db24085d..20661d0371 100644 --- a/pynest/pynestkernel.pyx +++ b/pynest/pynestkernel.pyx @@ -184,12 +184,13 @@ cdef class NESTEngine(object): cdef string modulepath_str = modulepath.encode() cdef char* arg0 = "pynest\0" - cdef char** argv_bytes = malloc(argc * sizeof(char*)) + cdef char** argv_bytes = 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): diff --git a/releasetools/buildnest.sh b/releasetools/buildnest.sh index 58c68fbd5d..986fdd7023 100755 --- a/releasetools/buildnest.sh +++ b/releasetools/buildnest.sh @@ -54,7 +54,7 @@ if ( $#argv != 0 ) then exit 0 endif else - set svndir="branches/nest-2.4/2.4.1" + set svndir="branches/nest-2.4/2.4.2" set branch="" endif @@ -118,7 +118,7 @@ svn --quiet checkout $svn_id $nest_srcdir # add svn revision number to tarball name set svnver=`svnversion $nest_srcdir` -set patchlevel = "1" +set patchlevel = "2" # move to nest_srcdir cd $nest_srcdir diff --git a/sli/slicontrol.cc b/sli/slicontrol.cc index 2a7cb0b462..a4c6db3002 100644 --- a/sli/slicontrol.cc +++ b/sli/slicontrol.cc @@ -1639,14 +1639,8 @@ void Token_sFunction::execute(SLIInterpreter *i) const } else { - std::string s; - char c; - i->OStack.push_move(t); - while(in.get(c)) - s+=c; - *sd = s; // this is correct, since sd points to the stringdatum on the - // ostack. + sd->erase(0, in.tellg()); i->OStack.push(true); } } @@ -1712,14 +1706,8 @@ void Symbol_sFunction::execute(SLIInterpreter *i) const } else { - std::string s; - char c; - i->OStack.push_move(t); - while(in.get(c)) - s+=c; - *sd = s; // this is correct, since sd points to the stringdatum on the - // ostack. + sd->erase(0, in.tellg()); i->OStack.push(true); } }