From 8bf610ecfe4f6fb1cf39426e5b934ad391df1007 Mon Sep 17 00:00:00 2001 From: Stine Vennemo Date: Wed, 7 Dec 2016 16:00:48 +0100 Subject: [PATCH 01/16] Fix 554, Added deprecation warnings, made sure examples avoid introduced deprecation warnings. --- pynest/examples/gif_population.py | 2 ++ pynest/examples/plot_quantal_stp_synapse.py | 6 ++++-- pynest/nest/lib/hl_api_connections.py | 1 + pynest/nest/lib/hl_api_models.py | 10 ++++++++++ pynest/nest/lib/hl_api_nodes.py | 17 +++++++++++++++++ pynest/nest/lib/hl_api_subnets.py | 12 ++++++++++++ topology/examples/ctx_2n.py | 16 ++++++++++------ topology/examples/grid_iaf.py | 4 ++-- topology/examples/grid_iaf_irr.py | 4 ++-- topology/examples/hill_tononi_Vp.py | 21 ++++++++++++++------- topology/examples/test_3d.py | 3 ++- topology/examples/test_3d_exp.py | 3 ++- topology/examples/test_3d_gauss.py | 3 ++- topology/pynest/hl_api.py | 10 ++++++++++ 14 files changed, 90 insertions(+), 22 deletions(-) diff --git a/pynest/examples/gif_population.py b/pynest/examples/gif_population.py index 9b1bc962d3..a050b9dce5 100644 --- a/pynest/examples/gif_population.py +++ b/pynest/examples/gif_population.py @@ -41,6 +41,8 @@ import nest.raster_plot import matplotlib.pyplot as plt +nest.ResetKernel() + ''' Assigning the simulation parameters to variables. ''' diff --git a/pynest/examples/plot_quantal_stp_synapse.py b/pynest/examples/plot_quantal_stp_synapse.py index 4ef72fec56..d6acbb5ff5 100644 --- a/pynest/examples/plot_quantal_stp_synapse.py +++ b/pynest/examples/plot_quantal_stp_synapse.py @@ -59,10 +59,12 @@ [30., 60., 90., 120., 150., 180., 210., 240., 270., 300., 330., 360., 390., 900.]}) +parrot = nest.Create('parrot_neuron') neuron = nest.Create("iaf_psc_exp", 2) -nest.Connect(source, [neuron[0]], syn_spec="tsodyks2_synapse") -nest.Connect(source, [neuron[1]], syn_spec="quantal_stp_synapse") +nest.Connect(source, parrot) +nest.Connect(parrot, neuron[:1], syn_spec="tsodyks2_synapse") +nest.Connect(parrot, neuron[1:], syn_spec="quantal_stp_synapse") voltmeter = nest.Create("voltmeter", 2) nest.SetStatus(voltmeter, {"withgid": False, "withtime": True}) diff --git a/pynest/nest/lib/hl_api_connections.py b/pynest/nest/lib/hl_api_connections.py index 18ca09921c..82868fbf94 100644 --- a/pynest/nest/lib/hl_api_connections.py +++ b/pynest/nest/lib/hl_api_connections.py @@ -350,6 +350,7 @@ def Connect(pre, post, conn_spec=None, syn_spec=None, model=None): @check_stack +@deprecated("", "DataConnect: use Connect() with one_to_one rule") def DataConnect(pre, params=None, model="static_synapse"): """Connect neurons from lists of connection data. diff --git a/pynest/nest/lib/hl_api_models.py b/pynest/nest/lib/hl_api_models.py index 3415665a34..2e7531da11 100644 --- a/pynest/nest/lib/hl_api_models.py +++ b/pynest/nest/lib/hl_api_models.py @@ -186,6 +186,16 @@ def CopyModel(existing, new, params=None): Default parameters assigned to the copy. Not provided parameters are taken from the existing model. """ + try: + deprecated_models = ['subnet', 'aeif_cond_alpha_RK5'] + if GetDefaults(existing)['type_id'] in deprecated_models: + text = "{0}: model is going to be removed".format(existing) + if existing == "subnet": + text += ", work with GIDCollections instead" + text = get_wrapped_text(text) + warnings.warn('\n' + text) + except(KeyError): + pass if params is not None: sps(params) diff --git a/pynest/nest/lib/hl_api_nodes.py b/pynest/nest/lib/hl_api_nodes.py index 4a632b2384..a79de1cc96 100644 --- a/pynest/nest/lib/hl_api_nodes.py +++ b/pynest/nest/lib/hl_api_nodes.py @@ -25,6 +25,10 @@ from .hl_api_helper import * from .hl_api_info import SetStatus +from .hl_api_models import GetDefaults +from ..pynestkernel import NESTError + +#import nest @check_stack @@ -47,6 +51,17 @@ def Create(model, n=1, params=None): Global IDs of created nodes """ + try: + deprecated_models = ['subnet', 'aeif_cond_alpha_RK5'] + if GetDefaults(model)['type_id'] in deprecated_models: + text = "{0}: model is going to be removed".format(model) + if model == "subnet": + text += ", work with GIDCollections instead" + text = get_wrapped_text(text) + warnings.warn('\n' + text) + except(KeyError, NESTError): + pass + if isinstance(params, dict): cmd = "/%s 3 1 roll exch Create" % model sps(params) @@ -72,6 +87,8 @@ def Create(model, n=1, params=None): @check_stack +@deprecated("", "GetLID: LIDs disappear with subnets, use index into " + "GIDCollection") def GetLID(gid): """Return the local id of a node with the global ID gid. diff --git a/pynest/nest/lib/hl_api_subnets.py b/pynest/nest/lib/hl_api_subnets.py index 1954ed1dbf..d6695388f4 100644 --- a/pynest/nest/lib/hl_api_subnets.py +++ b/pynest/nest/lib/hl_api_subnets.py @@ -55,6 +55,7 @@ def PrintNetwork(depth=1, subnet=None): sr("%i PrintNetwork" % depth) +@deprecated("", "CurrentSubnet: irrelevant without subnets") @check_stack def CurrentSubnet(): """Returns the global id of the current subnet. @@ -70,6 +71,7 @@ def CurrentSubnet(): @check_stack +@deprecated("", "ChangeSubnet: irrelevant without subnets") def ChangeSubnet(subnet): """Make given subnet the current. @@ -91,6 +93,7 @@ def ChangeSubnet(subnet): @check_stack +@deprecated("", "GetLeaves: elements of GIDCollection are leaves") def GetLeaves(subnets, properties=None, local_only=False): """Return the GIDs of the leaf nodes of the given subnets. @@ -130,6 +133,7 @@ def GetLeaves(subnets, properties=None, local_only=False): @check_stack +@deprecated("", "GetNodes: you have nodes in GIDCollections") def GetNodes(subnets, properties=None, local_only=False): """Return the global ids of the all nodes of the given subnets. @@ -167,6 +171,8 @@ def GetNodes(subnets, properties=None, local_only=False): @check_stack +@deprecated("", "GetChildren: irrelevant without subnets, work with " + "GIDCollections") def GetChildren(subnets, properties=None, local_only=False): """Return the global ids of the immediate children of the given subnets. @@ -204,6 +210,8 @@ def GetChildren(subnets, properties=None, local_only=False): @check_stack +@deprecated("", "GetNetwork: irrelevant without subnets, script is responsible " + "for retaining structure information if needed") def GetNetwork(gid, depth): """Return a nested list with the children of subnet id at level depth. @@ -236,6 +244,7 @@ def GetNetwork(gid, depth): @check_stack +@deprecated("", "BeginSubnet: no longer needed, work with GIDCollections") def BeginSubnet(label=None, params=None): """Create a new subnet and change into it. @@ -256,6 +265,7 @@ def BeginSubnet(label=None, params=None): @check_stack +@deprecated("", "EndSubnet: no longer needed, work with GIDCollections") def EndSubnet(): """Change to the parent subnet and return the gid of the current. @@ -277,6 +287,8 @@ def EndSubnet(): @check_stack +@deprecated("", "LayoutNetwork: use Create(, n=) and get a " + "GIDCollection") def LayoutNetwork(model, dim, label=None, params=None): """Create a subnetwork of dimension dim with nodes of type model and return a list of ids. diff --git a/topology/examples/ctx_2n.py b/topology/examples/ctx_2n.py index 76dda0ccaf..e1afe585f1 100644 --- a/topology/examples/ctx_2n.py +++ b/topology/examples/ctx_2n.py @@ -40,22 +40,26 @@ nest.CopyModel('iaf_neuron', 'pyr') nest.CopyModel('iaf_neuron', 'in') -ctx = topo.CreateLayer({'columns': 4, 'rows': 3, +col = 4 +row = 3 +el = ['pyr', 'in'] +ctx = topo.CreateLayer({'columns': col, 'rows': row, 'extent': [2.0, 1.5], - 'elements': ['pyr', 'in']}) + 'elements': el}) -nest.PrintNetwork() +nest.PrintNetwork(1,(0,)) -nest.PrintNetwork(2) +nest.PrintNetwork(2,(0,)) nest.PrintNetwork(2, ctx) +gids = range(ctx[0] + 1, col*row*len(el) + ctx[0] + 1) # extract position information ppyr = pylab.array( - tuple(zip(*[topo.GetPosition([n])[0] for n in nest.GetLeaves(ctx)[0] + tuple(zip(*[topo.GetPosition([n])[0] for n in gids if nest.GetStatus([n], 'model')[0] == 'pyr']))) pin = pylab.array( - tuple(zip(*[topo.GetPosition([n])[0] for n in nest.GetLeaves(ctx)[0] + tuple(zip(*[topo.GetPosition([n])[0] for n in gids if nest.GetStatus([n], 'model')[0] == 'in']))) # plot pylab.clf() diff --git a/topology/examples/grid_iaf.py b/topology/examples/grid_iaf.py index 0a95e24828..a6afbc8b49 100644 --- a/topology/examples/grid_iaf.py +++ b/topology/examples/grid_iaf.py @@ -40,8 +40,8 @@ 'extent': [2.0, 1.5], 'elements': 'iaf_neuron'}) -nest.PrintNetwork() -nest.PrintNetwork(2) +nest.PrintNetwork(1, (0,)) +nest.PrintNetwork(2, (0,)) nest.PrintNetwork(2, l1) topo.PlotLayer(l1, nodesize=50) diff --git a/topology/examples/grid_iaf_irr.py b/topology/examples/grid_iaf_irr.py index 8fa6272583..a77d627a33 100644 --- a/topology/examples/grid_iaf_irr.py +++ b/topology/examples/grid_iaf_irr.py @@ -45,8 +45,8 @@ 'positions': pos, 'elements': 'iaf_neuron'}) -nest.PrintNetwork() -nest.PrintNetwork(2) +nest.PrintNetwork(1, (0,)) +nest.PrintNetwork(2, (0,)) nest.PrintNetwork(2, l1) topo.PlotLayer(l1, nodesize=50) diff --git a/topology/examples/hill_tononi_Vp.py b/topology/examples/hill_tononi_Vp.py index 617df22e27..fadb8cb66e 100644 --- a/topology/examples/hill_tononi_Vp.py +++ b/topology/examples/hill_tononi_Vp.py @@ -377,12 +377,14 @@ def phaseInit(pos, lam, alpha): layerProps.update({'elements': 'RetinaNode'}) retina = topo.CreateLayer(layerProps) +gids = range(retina[0] + 1, retina[0] + Params['N']*Params['N'] + 1) + # ! Now set phases of retinal oscillators; we use a list comprehension instead # ! of a loop. [nest.SetStatus([n], {"phase": phaseInit(topo.GetPosition([n])[0], Params["lambda_dg"], Params["phi_dg"])}) - for n in nest.GetLeaves(retina)[0]] + for n in gids] # ! Thalamus # ! -------- @@ -400,6 +402,7 @@ def phaseInit(pos, lam, alpha): # ! interneuron per location: layerProps.update({'elements': ['TpRelay', 'TpInter']}) Tp = topo.CreateLayer(layerProps) +gids_Tp = range(Tp[0] + 1, Params['N']*Params['N']*len(layerProps['elements']) + Tp[0] + 1) # ! Reticular nucleus # ! ----------------- @@ -409,6 +412,7 @@ def phaseInit(pos, lam, alpha): ('RpNeuron',)] layerProps.update({'elements': 'RpNeuron'}) Rp = topo.CreateLayer(layerProps) +gids_Rp = range(Rp[0] + 1, Params['N']*Params['N'] + Rp[0] + 1) # ! Primary visual cortex # ! --------------------- @@ -433,6 +437,8 @@ def phaseInit(pos, lam, alpha): 'L56pyr', 2, 'L56in', 1]}) Vp_h = topo.CreateLayer(layerProps) Vp_v = topo.CreateLayer(layerProps) +gids_Vp_h = range(Vp_h[0] + 1, Params['N']*Params['N']*9 + Vp_h[0] + 1) +gids_Vp_v = range(Vp_v[0] + 1, Params['N']*Params['N']*9 + Vp_v[0] + 1) # ! Collect all populations # ! ----------------------- @@ -445,7 +451,7 @@ def phaseInit(pos, lam, alpha): # ! ---------- # ! We can now look at the network using `PrintNetwork`: -nest.PrintNetwork() +nest.PrintNetwork(1, (0,)) # ! We can also try to plot a single layer in a network. For # ! simplicity, we use Rp, which has only a single neuron per position. @@ -817,12 +823,13 @@ def phaseInit(pos, lam, alpha): # ! connect. ``loc`` is the subplot location for the layer. print("Connecting: Recording devices") recorders = {} -for name, loc, population, model in [('TpRelay', 1, Tp, 'TpRelay'), - ('Rp', 2, Rp, 'RpNeuron'), - ('Vp_v L4pyr', 3, Vp_v, 'L4pyr'), - ('Vp_h L4pyr', 4, Vp_h, 'L4pyr')]: +gids = [gids_Tp, gids_Rp, gids_Vp_v, gids_Vp_h] +for name, loc, model in [('TpRelay', 1, 'TpRelay'), + ('Rp', 2, 'RpNeuron'), + ('Vp_v L4pyr', 3, 'L4pyr'), + ('Vp_h L4pyr', 4, 'L4pyr')]: recorders[name] = (nest.Create('RecordingNode'), loc) - tgts = [nd for nd in nest.GetLeaves(population)[0] + tgts = [nd for nd in gids[loc-1] if nest.GetStatus([nd], 'model')[0] == model] nest.Connect(recorders[name][0], tgts) # one recorder to all targets diff --git a/topology/examples/test_3d.py b/topology/examples/test_3d.py index 3c40052ef6..8125a8d8c9 100644 --- a/topology/examples/test_3d.py +++ b/topology/examples/test_3d.py @@ -55,8 +55,9 @@ # xext, yext = nest.GetStatus(l1, 'topology')[0]['extent'] # xctr, yctr = nest.GetStatus(l1, 'topology')[0]['center'] +gids = range(l1[0] + 1, len(pos) + l1[0] + 1) # extract position information, transpose to list of x, y and z positions -xpos, ypos, zpos = zip(*topo.GetPosition(nest.GetChildren(l1)[0])) +xpos, ypos, zpos = zip(*topo.GetPosition(gids)) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter(xpos, ypos, zpos, s=15, facecolor='b', edgecolor='none') diff --git a/topology/examples/test_3d_exp.py b/topology/examples/test_3d_exp.py index 6079479dd4..001419c2e8 100644 --- a/topology/examples/test_3d_exp.py +++ b/topology/examples/test_3d_exp.py @@ -56,7 +56,8 @@ # xctr, yctr = nest.GetStatus(l1, 'topology')[0]['center'] # extract position information, transpose to list of x, y and z positions -xpos, ypos, zpos = zip(*topo.GetPosition(nest.GetChildren(l1)[0])) +gids = range(l1[0] + 1, len(pos) + l1[0] + 1) +xpos, ypos, zpos = zip(*topo.GetPosition(gids)) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter(xpos, ypos, zpos, s=15, facecolor='b', edgecolor='none') diff --git a/topology/examples/test_3d_gauss.py b/topology/examples/test_3d_gauss.py index 36f306d1e3..d414c5562d 100644 --- a/topology/examples/test_3d_gauss.py +++ b/topology/examples/test_3d_gauss.py @@ -55,8 +55,9 @@ # xext, yext = nest.GetStatus(l1, 'topology')[0]['extent'] # xctr, yctr = nest.GetStatus(l1, 'topology')[0]['center'] +gids = range(l1[0] + 1, len(pos) + l1[0] + 1) # extract position information, transpose to list of x, y and z positions -xpos, ypos, zpos = zip(*topo.GetPosition(nest.GetChildren(l1)[0])) +xpos, ypos, zpos = zip(*topo.GetPosition(gids)) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter(xpos, ypos, zpos, s=15, facecolor='b', edgecolor='none') diff --git a/topology/pynest/hl_api.py b/topology/pynest/hl_api.py index e30d8a9d1c..62b03a8559 100644 --- a/topology/pynest/hl_api.py +++ b/topology/pynest/hl_api.py @@ -64,6 +64,7 @@ """ import nest +import nest.lib.hl_api_helper as hlh def topology_func(slifunc, *args): @@ -1610,6 +1611,9 @@ def GetTargetNodes(sources, tgt_layer, tgt_model=None, syn_model=None): if len(tgt_layer) != 1: raise nest.NESTError("tgt_layer must be a one-element list") + # Turn of deprecation warning as users shouldn't change implementation of + # GetTargetNodes, it is done by the developers + hlh._deprecation_warning['GetLeaves'] = False # obtain local nodes in target layer, to pass to GetConnections tgt_nodes = nest.GetLeaves(tgt_layer, properties={ @@ -1786,6 +1790,9 @@ def PlotLayer(layer, fig=None, nodecolor='b', nodesize=20): xext, yext = ext xctr, yctr = nest.GetStatus(layer, 'topology')[0]['center'] + # Turn of deprecation warning as users shouldn't change implementation + # of PlotLayer, it is done by the developers + hlh._deprecation_warning['GetChildren'] = False # extract position information, transpose to list of x and y positions xpos, ypos = zip(*GetPosition(nest.GetChildren(layer)[0])) @@ -1803,6 +1810,9 @@ def PlotLayer(layer, fig=None, nodecolor='b', nodesize=20): # 3D layer from mpl_toolkits.mplot3d import Axes3D + # Turn of deprecation warning as users shouldn't change implementation of + # GetTargetNodes, it is done by the developers + hlh._deprecation_warning['GetLeaves'] = False # extract position information, transpose to list of x,y,z positions pos = zip(*GetPosition(nest.GetChildren(layer)[0])) From 425aca4584b3e9ed227ebda6c7dfa3568c7b2913 Mon Sep 17 00:00:00 2001 From: Stine Vennemo Date: Wed, 7 Dec 2016 16:14:32 +0100 Subject: [PATCH 02/16] Fix formatting --- pynest/nest/lib/hl_api_nodes.py | 2 -- pynest/nest/lib/hl_api_subnets.py | 4 ++-- topology/examples/ctx_2n.py | 4 ++-- topology/examples/hill_tononi_Vp.py | 10 ++++++---- topology/pynest/hl_api.py | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pynest/nest/lib/hl_api_nodes.py b/pynest/nest/lib/hl_api_nodes.py index a79de1cc96..64f3e5b016 100644 --- a/pynest/nest/lib/hl_api_nodes.py +++ b/pynest/nest/lib/hl_api_nodes.py @@ -28,8 +28,6 @@ from .hl_api_models import GetDefaults from ..pynestkernel import NESTError -#import nest - @check_stack def Create(model, n=1, params=None): diff --git a/pynest/nest/lib/hl_api_subnets.py b/pynest/nest/lib/hl_api_subnets.py index d6695388f4..b7a45c146f 100644 --- a/pynest/nest/lib/hl_api_subnets.py +++ b/pynest/nest/lib/hl_api_subnets.py @@ -210,8 +210,8 @@ def GetChildren(subnets, properties=None, local_only=False): @check_stack -@deprecated("", "GetNetwork: irrelevant without subnets, script is responsible " - "for retaining structure information if needed") +@deprecated("", "GetNetwork: irrelevant without subnets, script is responsible" + " for retaining structure information if needed") def GetNetwork(gid, depth): """Return a nested list with the children of subnet id at level depth. diff --git a/topology/examples/ctx_2n.py b/topology/examples/ctx_2n.py index e1afe585f1..068ca30ccb 100644 --- a/topology/examples/ctx_2n.py +++ b/topology/examples/ctx_2n.py @@ -47,9 +47,9 @@ 'extent': [2.0, 1.5], 'elements': el}) -nest.PrintNetwork(1,(0,)) +nest.PrintNetwork(1, (0,)) -nest.PrintNetwork(2,(0,)) +nest.PrintNetwork(2, (0,)) nest.PrintNetwork(2, ctx) diff --git a/topology/examples/hill_tononi_Vp.py b/topology/examples/hill_tononi_Vp.py index fadb8cb66e..5d73ba8ce7 100644 --- a/topology/examples/hill_tononi_Vp.py +++ b/topology/examples/hill_tononi_Vp.py @@ -402,7 +402,9 @@ def phaseInit(pos, lam, alpha): # ! interneuron per location: layerProps.update({'elements': ['TpRelay', 'TpInter']}) Tp = topo.CreateLayer(layerProps) -gids_Tp = range(Tp[0] + 1, Params['N']*Params['N']*len(layerProps['elements']) + Tp[0] + 1) +gids_Tp = range(Tp[0] + 1, + Params['N']*Params['N']*len(layerProps['elements']) + + Tp[0] + 1) # ! Reticular nucleus # ! ----------------- @@ -825,9 +827,9 @@ def phaseInit(pos, lam, alpha): recorders = {} gids = [gids_Tp, gids_Rp, gids_Vp_v, gids_Vp_h] for name, loc, model in [('TpRelay', 1, 'TpRelay'), - ('Rp', 2, 'RpNeuron'), - ('Vp_v L4pyr', 3, 'L4pyr'), - ('Vp_h L4pyr', 4, 'L4pyr')]: + ('Rp', 2, 'RpNeuron'), + ('Vp_v L4pyr', 3, 'L4pyr'), + ('Vp_h L4pyr', 4, 'L4pyr')]: recorders[name] = (nest.Create('RecordingNode'), loc) tgts = [nd for nd in gids[loc-1] if nest.GetStatus([nd], 'model')[0] == model] diff --git a/topology/pynest/hl_api.py b/topology/pynest/hl_api.py index 62b03a8559..e1d20a09dd 100644 --- a/topology/pynest/hl_api.py +++ b/topology/pynest/hl_api.py @@ -1611,7 +1611,7 @@ def GetTargetNodes(sources, tgt_layer, tgt_model=None, syn_model=None): if len(tgt_layer) != 1: raise nest.NESTError("tgt_layer must be a one-element list") - # Turn of deprecation warning as users shouldn't change implementation of + # Turn of deprecation warning as users shouldn't change implementation of # GetTargetNodes, it is done by the developers hlh._deprecation_warning['GetLeaves'] = False # obtain local nodes in target layer, to pass to GetConnections @@ -1810,9 +1810,9 @@ def PlotLayer(layer, fig=None, nodecolor='b', nodesize=20): # 3D layer from mpl_toolkits.mplot3d import Axes3D - # Turn of deprecation warning as users shouldn't change implementation of - # GetTargetNodes, it is done by the developers - hlh._deprecation_warning['GetLeaves'] = False + # Turn of deprecation warning as users shouldn't change implementation + # of PlotLayer, it is done by the developers + hlh._deprecation_warning['GetChildren'] = False # extract position information, transpose to list of x,y,z positions pos = zip(*GetPosition(nest.GetChildren(layer)[0])) From c5ff0bcc25025a5ea84f3915a5297d61480dcb35 Mon Sep 17 00:00:00 2001 From: Stine Vennemo Date: Fri, 9 Dec 2016 10:01:04 +0100 Subject: [PATCH 03/16] Changed the deprecation warnings, made a helper function for models that are deprecated, made sure PrintNetwork does not display deprecation warning, re-did examples. --- pynest/nest/lib/hl_api_connections.py | 3 ++- pynest/nest/lib/hl_api_helper.py | 23 ++++++++++++++++ pynest/nest/lib/hl_api_models.py | 12 ++------- pynest/nest/lib/hl_api_nodes.py | 17 +++--------- pynest/nest/lib/hl_api_subnets.py | 38 ++++++++++++++++++--------- topology/examples/ctx_2n.py | 19 +++++++------- topology/examples/grid_iaf.py | 4 +-- topology/examples/grid_iaf_irr.py | 4 +-- topology/examples/hill_tononi_Vp.py | 26 ++++++++---------- topology/examples/test_3d.py | 6 +++-- topology/examples/test_3d_exp.py | 6 +++-- topology/examples/test_3d_gauss.py | 6 +++-- topology/pynest/hl_api.py | 21 ++++++++++----- 13 files changed, 107 insertions(+), 78 deletions(-) diff --git a/pynest/nest/lib/hl_api_connections.py b/pynest/nest/lib/hl_api_connections.py index 82868fbf94..78637bfa89 100644 --- a/pynest/nest/lib/hl_api_connections.py +++ b/pynest/nest/lib/hl_api_connections.py @@ -350,7 +350,8 @@ def Connect(pre, post, conn_spec=None, syn_spec=None, model=None): @check_stack -@deprecated("", "DataConnect: use Connect() with one_to_one rule") +@deprecated('', 'DataConnect is deprecated and will be removed in NEST3. Use \ +Connect() with one_to_one rule instead.') def DataConnect(pre, params=None, model="static_synapse"): """Connect neurons from lists of connection data. diff --git a/pynest/nest/lib/hl_api_helper.py b/pynest/nest/lib/hl_api_helper.py index 49f1e739d9..dcb3adb22b 100644 --- a/pynest/nest/lib/hl_api_helper.py +++ b/pynest/nest/lib/hl_api_helper.py @@ -24,6 +24,8 @@ API of the PyNEST wrapper. """ + +import nest import warnings import inspect import functools @@ -398,3 +400,24 @@ def broadcast(item, length, allowed_types, name="item"): % (name, length)) return item + + +def model_deprecation_warning(model): + """Checks whether the model is to be removed in a future verstion of NEST. + If so, a deprecation warning is released. + + Parameters + ---------- + model: str + Name of model + """ + + deprecated_models = {'subnet': 'GIDCollection', + 'aeif_cond_alpha_RK5': 'aeif_cond_alpha'} + + if model in deprecated_models: + text = "The {0} model is deprecated and will be removed in a \ + future verstion of NEST, use {1} instead\ + ".format(model, deprecated_models[model]) + text = get_wrapped_text(text) + warnings.warn('\n' + text) diff --git a/pynest/nest/lib/hl_api_models.py b/pynest/nest/lib/hl_api_models.py index 2e7531da11..6d714be988 100644 --- a/pynest/nest/lib/hl_api_models.py +++ b/pynest/nest/lib/hl_api_models.py @@ -186,16 +186,8 @@ def CopyModel(existing, new, params=None): Default parameters assigned to the copy. Not provided parameters are taken from the existing model. """ - try: - deprecated_models = ['subnet', 'aeif_cond_alpha_RK5'] - if GetDefaults(existing)['type_id'] in deprecated_models: - text = "{0}: model is going to be removed".format(existing) - if existing == "subnet": - text += ", work with GIDCollections instead" - text = get_wrapped_text(text) - warnings.warn('\n' + text) - except(KeyError): - pass + + model_deprecation_warning(existing) if params is not None: sps(params) diff --git a/pynest/nest/lib/hl_api_nodes.py b/pynest/nest/lib/hl_api_nodes.py index 64f3e5b016..923f02c2eb 100644 --- a/pynest/nest/lib/hl_api_nodes.py +++ b/pynest/nest/lib/hl_api_nodes.py @@ -25,8 +25,6 @@ from .hl_api_helper import * from .hl_api_info import SetStatus -from .hl_api_models import GetDefaults -from ..pynestkernel import NESTError @check_stack @@ -49,16 +47,7 @@ def Create(model, n=1, params=None): Global IDs of created nodes """ - try: - deprecated_models = ['subnet', 'aeif_cond_alpha_RK5'] - if GetDefaults(model)['type_id'] in deprecated_models: - text = "{0}: model is going to be removed".format(model) - if model == "subnet": - text += ", work with GIDCollections instead" - text = get_wrapped_text(text) - warnings.warn('\n' + text) - except(KeyError, NESTError): - pass + model_deprecation_warning(model) if isinstance(params, dict): cmd = "/%s 3 1 roll exch Create" % model @@ -85,8 +74,8 @@ def Create(model, n=1, params=None): @check_stack -@deprecated("", "GetLID: LIDs disappear with subnets, use index into " - "GIDCollection") +@deprecated('', 'GetLID is deprecated and will be removed in NEST3. Use \ +index into GIDCollection instead.') def GetLID(gid): """Return the local id of a node with the global ID gid. diff --git a/pynest/nest/lib/hl_api_subnets.py b/pynest/nest/lib/hl_api_subnets.py index b7a45c146f..cb2170ae4b 100644 --- a/pynest/nest/lib/hl_api_subnets.py +++ b/pynest/nest/lib/hl_api_subnets.py @@ -27,6 +27,8 @@ from .hl_api_nodes import Create from .hl_api_info import GetStatus, SetStatus +import nest.lib.hl_api_helper as hlh + @check_stack def PrintNetwork(depth=1, subnet=None): @@ -47,7 +49,15 @@ def PrintNetwork(depth=1, subnet=None): """ if subnet is None: + # Turn off _deprecation_warning as users shouldn't change + # implementation of PrintNetwork, it is done by the developers + deprecation_bool = hlh._deprecation_warning['CurrentSubnet'] + hlh._deprecation_warning['CurrentSubnet'] = False + subnet = CurrentSubnet() + + # Need to reset the deprecation warning to its old value + hlh._deprecation_warning['CurrentSubnet'] = deprecation_bool elif len(subnet) > 1: raise NESTError("PrintNetwork() expects exactly one GID.") @@ -55,8 +65,8 @@ def PrintNetwork(depth=1, subnet=None): sr("%i PrintNetwork" % depth) -@deprecated("", "CurrentSubnet: irrelevant without subnets") @check_stack +@deprecated('', 'CurrentSubnet is deprecated and will be removed in NEST3.') def CurrentSubnet(): """Returns the global id of the current subnet. @@ -71,7 +81,7 @@ def CurrentSubnet(): @check_stack -@deprecated("", "ChangeSubnet: irrelevant without subnets") +@deprecated('', 'ChangeSubnet is deprecated and will be removed in NEST3.') def ChangeSubnet(subnet): """Make given subnet the current. @@ -93,7 +103,8 @@ def ChangeSubnet(subnet): @check_stack -@deprecated("", "GetLeaves: elements of GIDCollection are leaves") +@deprecated('', 'GetLeaves is deprecated and will be removed in NEST3. Use \ +GIDCollection instead.') def GetLeaves(subnets, properties=None, local_only=False): """Return the GIDs of the leaf nodes of the given subnets. @@ -133,7 +144,8 @@ def GetLeaves(subnets, properties=None, local_only=False): @check_stack -@deprecated("", "GetNodes: you have nodes in GIDCollections") +@deprecated('', 'GetNodes is deprecated and will be removed in NEST3. Use \ +GIDCollection instead.') def GetNodes(subnets, properties=None, local_only=False): """Return the global ids of the all nodes of the given subnets. @@ -171,8 +183,8 @@ def GetNodes(subnets, properties=None, local_only=False): @check_stack -@deprecated("", "GetChildren: irrelevant without subnets, work with " - "GIDCollections") +@deprecated('', 'GetChilden is deprecated and will be removed in NEST3. Use \ +GIDCollection instead.') def GetChildren(subnets, properties=None, local_only=False): """Return the global ids of the immediate children of the given subnets. @@ -210,8 +222,8 @@ def GetChildren(subnets, properties=None, local_only=False): @check_stack -@deprecated("", "GetNetwork: irrelevant without subnets, script is responsible" - " for retaining structure information if needed") +@deprecated('', 'GetNetwork is deprecated and will be removed in Nest3.\ +Script is responsible for retaining structure information if needed') def GetNetwork(gid, depth): """Return a nested list with the children of subnet id at level depth. @@ -244,7 +256,8 @@ def GetNetwork(gid, depth): @check_stack -@deprecated("", "BeginSubnet: no longer needed, work with GIDCollections") +@deprecated('', 'BeginSubnet is deprecated and will be removed in NEST3. Use \ +GIDCollection instead.') def BeginSubnet(label=None, params=None): """Create a new subnet and change into it. @@ -265,7 +278,8 @@ def BeginSubnet(label=None, params=None): @check_stack -@deprecated("", "EndSubnet: no longer needed, work with GIDCollections") +@deprecated('', 'EndSubnet is deprecated and will be removed in NEST3. Use \ +GIDCollection instead.') def EndSubnet(): """Change to the parent subnet and return the gid of the current. @@ -287,8 +301,8 @@ def EndSubnet(): @check_stack -@deprecated("", "LayoutNetwork: use Create(, n=) and get a " - "GIDCollection") +@deprecated('', 'LayoutNetwork is deprecated and will be removed in NEST3. Use \ +Create(, n=) instead.') def LayoutNetwork(model, dim, label=None, params=None): """Create a subnetwork of dimension dim with nodes of type model and return a list of ids. diff --git a/topology/examples/ctx_2n.py b/topology/examples/ctx_2n.py index 068ca30ccb..8caba2dd26 100644 --- a/topology/examples/ctx_2n.py +++ b/topology/examples/ctx_2n.py @@ -40,26 +40,25 @@ nest.CopyModel('iaf_neuron', 'pyr') nest.CopyModel('iaf_neuron', 'in') -col = 4 -row = 3 -el = ['pyr', 'in'] -ctx = topo.CreateLayer({'columns': col, 'rows': row, +ctx = topo.CreateLayer({'columns': 4, 'rows': 3, 'extent': [2.0, 1.5], - 'elements': el}) + 'elements': ['pyr', 'in']}) -nest.PrintNetwork(1, (0,)) +nest.PrintNetwork() -nest.PrintNetwork(2, (0,)) +nest.PrintNetwork(2) nest.PrintNetwork(2, ctx) -gids = range(ctx[0] + 1, col*row*len(el) + ctx[0] + 1) +# ctx_leaves is a work-around until NEST3 is released +ctx_leaves = nest.GetLeaves(ctx)[0] + # extract position information ppyr = pylab.array( - tuple(zip(*[topo.GetPosition([n])[0] for n in gids + tuple(zip(*[topo.GetPosition([n])[0] for n in ctx_leaves if nest.GetStatus([n], 'model')[0] == 'pyr']))) pin = pylab.array( - tuple(zip(*[topo.GetPosition([n])[0] for n in gids + tuple(zip(*[topo.GetPosition([n])[0] for n in ctx_leaves if nest.GetStatus([n], 'model')[0] == 'in']))) # plot pylab.clf() diff --git a/topology/examples/grid_iaf.py b/topology/examples/grid_iaf.py index a6afbc8b49..0a95e24828 100644 --- a/topology/examples/grid_iaf.py +++ b/topology/examples/grid_iaf.py @@ -40,8 +40,8 @@ 'extent': [2.0, 1.5], 'elements': 'iaf_neuron'}) -nest.PrintNetwork(1, (0,)) -nest.PrintNetwork(2, (0,)) +nest.PrintNetwork() +nest.PrintNetwork(2) nest.PrintNetwork(2, l1) topo.PlotLayer(l1, nodesize=50) diff --git a/topology/examples/grid_iaf_irr.py b/topology/examples/grid_iaf_irr.py index a77d627a33..8fa6272583 100644 --- a/topology/examples/grid_iaf_irr.py +++ b/topology/examples/grid_iaf_irr.py @@ -45,8 +45,8 @@ 'positions': pos, 'elements': 'iaf_neuron'}) -nest.PrintNetwork(1, (0,)) -nest.PrintNetwork(2, (0,)) +nest.PrintNetwork() +nest.PrintNetwork(2) nest.PrintNetwork(2, l1) topo.PlotLayer(l1, nodesize=50) diff --git a/topology/examples/hill_tononi_Vp.py b/topology/examples/hill_tononi_Vp.py index 5d73ba8ce7..5ad4cd05a8 100644 --- a/topology/examples/hill_tononi_Vp.py +++ b/topology/examples/hill_tononi_Vp.py @@ -377,14 +377,15 @@ def phaseInit(pos, lam, alpha): layerProps.update({'elements': 'RetinaNode'}) retina = topo.CreateLayer(layerProps) -gids = range(retina[0] + 1, retina[0] + Params['N']*Params['N'] + 1) +# retina_leaves is a work-around until NEST3 is released +retina_leaves = nest.GetLeaves(retina)[0] # ! Now set phases of retinal oscillators; we use a list comprehension instead # ! of a loop. [nest.SetStatus([n], {"phase": phaseInit(topo.GetPosition([n])[0], Params["lambda_dg"], Params["phi_dg"])}) - for n in gids] + for n in retina_leaves] # ! Thalamus # ! -------- @@ -402,9 +403,6 @@ def phaseInit(pos, lam, alpha): # ! interneuron per location: layerProps.update({'elements': ['TpRelay', 'TpInter']}) Tp = topo.CreateLayer(layerProps) -gids_Tp = range(Tp[0] + 1, - Params['N']*Params['N']*len(layerProps['elements']) + - Tp[0] + 1) # ! Reticular nucleus # ! ----------------- @@ -414,7 +412,6 @@ def phaseInit(pos, lam, alpha): ('RpNeuron',)] layerProps.update({'elements': 'RpNeuron'}) Rp = topo.CreateLayer(layerProps) -gids_Rp = range(Rp[0] + 1, Params['N']*Params['N'] + Rp[0] + 1) # ! Primary visual cortex # ! --------------------- @@ -439,8 +436,6 @@ def phaseInit(pos, lam, alpha): 'L56pyr', 2, 'L56in', 1]}) Vp_h = topo.CreateLayer(layerProps) Vp_v = topo.CreateLayer(layerProps) -gids_Vp_h = range(Vp_h[0] + 1, Params['N']*Params['N']*9 + Vp_h[0] + 1) -gids_Vp_v = range(Vp_v[0] + 1, Params['N']*Params['N']*9 + Vp_v[0] + 1) # ! Collect all populations # ! ----------------------- @@ -453,7 +448,7 @@ def phaseInit(pos, lam, alpha): # ! ---------- # ! We can now look at the network using `PrintNetwork`: -nest.PrintNetwork(1, (0,)) +nest.PrintNetwork() # ! We can also try to plot a single layer in a network. For # ! simplicity, we use Rp, which has only a single neuron per position. @@ -825,13 +820,14 @@ def phaseInit(pos, lam, alpha): # ! connect. ``loc`` is the subplot location for the layer. print("Connecting: Recording devices") recorders = {} -gids = [gids_Tp, gids_Rp, gids_Vp_v, gids_Vp_h] -for name, loc, model in [('TpRelay', 1, 'TpRelay'), - ('Rp', 2, 'RpNeuron'), - ('Vp_v L4pyr', 3, 'L4pyr'), - ('Vp_h L4pyr', 4, 'L4pyr')]: +for name, loc, population, model in [('TpRelay', 1, Tp, 'TpRelay'), + ('Rp', 2, Rp, 'RpNeuron'), + ('Vp_v L4pyr', 3, Vp_v, 'L4pyr'), + ('Vp_h L4pyr', 4, Vp_h, 'L4pyr')]: recorders[name] = (nest.Create('RecordingNode'), loc) - tgts = [nd for nd in gids[loc-1] + # population_leaves is a work-around until NEST3 is released + population_leaves = nest.GetLeaves(population)[0] + tgts = [nd for nd in population_leaves if nest.GetStatus([nd], 'model')[0] == model] nest.Connect(recorders[name][0], tgts) # one recorder to all targets diff --git a/topology/examples/test_3d.py b/topology/examples/test_3d.py index 8125a8d8c9..b56a486eeb 100644 --- a/topology/examples/test_3d.py +++ b/topology/examples/test_3d.py @@ -55,9 +55,11 @@ # xext, yext = nest.GetStatus(l1, 'topology')[0]['extent'] # xctr, yctr = nest.GetStatus(l1, 'topology')[0]['center'] -gids = range(l1[0] + 1, len(pos) + l1[0] + 1) +# l1_children is a work-around until NEST3 is released +l1_children = nest.GetChildren(l1)[0] + # extract position information, transpose to list of x, y and z positions -xpos, ypos, zpos = zip(*topo.GetPosition(gids)) +xpos, ypos, zpos = zip(*topo.GetPosition(l1_children)) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter(xpos, ypos, zpos, s=15, facecolor='b', edgecolor='none') diff --git a/topology/examples/test_3d_exp.py b/topology/examples/test_3d_exp.py index 001419c2e8..64e8c0262b 100644 --- a/topology/examples/test_3d_exp.py +++ b/topology/examples/test_3d_exp.py @@ -55,9 +55,11 @@ # xext, yext = nest.GetStatus(l1, 'topology')[0]['extent'] # xctr, yctr = nest.GetStatus(l1, 'topology')[0]['center'] +# l1_children is a work-around until NEST3 is released +l1_children = nest.GetChildren(l1)[0] + # extract position information, transpose to list of x, y and z positions -gids = range(l1[0] + 1, len(pos) + l1[0] + 1) -xpos, ypos, zpos = zip(*topo.GetPosition(gids)) +xpos, ypos, zpos = zip(*topo.GetPosition(l1_children)) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter(xpos, ypos, zpos, s=15, facecolor='b', edgecolor='none') diff --git a/topology/examples/test_3d_gauss.py b/topology/examples/test_3d_gauss.py index d414c5562d..31b9e12ed3 100644 --- a/topology/examples/test_3d_gauss.py +++ b/topology/examples/test_3d_gauss.py @@ -55,9 +55,11 @@ # xext, yext = nest.GetStatus(l1, 'topology')[0]['extent'] # xctr, yctr = nest.GetStatus(l1, 'topology')[0]['center'] -gids = range(l1[0] + 1, len(pos) + l1[0] + 1) +# l1_children is a work-around until NEST3 is released +l1_children = nest.GetChildren(l1)[0] + # extract position information, transpose to list of x, y and z positions -xpos, ypos, zpos = zip(*topo.GetPosition(gids)) +xpos, ypos, zpos = zip(*topo.GetPosition(l1_children)) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter(xpos, ypos, zpos, s=15, facecolor='b', edgecolor='none') diff --git a/topology/pynest/hl_api.py b/topology/pynest/hl_api.py index e1d20a09dd..6c70f2ebff 100644 --- a/topology/pynest/hl_api.py +++ b/topology/pynest/hl_api.py @@ -1611,14 +1611,17 @@ def GetTargetNodes(sources, tgt_layer, tgt_model=None, syn_model=None): if len(tgt_layer) != 1: raise nest.NESTError("tgt_layer must be a one-element list") - # Turn of deprecation warning as users shouldn't change implementation of - # GetTargetNodes, it is done by the developers + # Turn off _deprecation _warning as users shouldn't change implementation + # of GetTargetNodes, it is done by the developers + deprecation_bool = hlh._deprecation_warning['GetLeaves'] hlh._deprecation_warning['GetLeaves'] = False # obtain local nodes in target layer, to pass to GetConnections tgt_nodes = nest.GetLeaves(tgt_layer, properties={ 'model': tgt_model} if tgt_model else None, local_only=True)[0] + # Need to reset the deprecation warning to its old value + hlh._deprecation_warning['GetLeaves'] = deprecation_bool conns = nest.GetConnections(sources, tgt_nodes, synapse_model=syn_model) @@ -1790,11 +1793,14 @@ def PlotLayer(layer, fig=None, nodecolor='b', nodesize=20): xext, yext = ext xctr, yctr = nest.GetStatus(layer, 'topology')[0]['center'] - # Turn of deprecation warning as users shouldn't change implementation - # of PlotLayer, it is done by the developers + # Turn off _deprecation_warning as users shouldn't change + # implementation of PlotLayer, it is done by the developers + deprecation_bool = hlh._deprecation_warning['GetChildren'] hlh._deprecation_warning['GetChildren'] = False # extract position information, transpose to list of x and y positions xpos, ypos = zip(*GetPosition(nest.GetChildren(layer)[0])) + # Need to reset the deprecation warning to its old value + hlh._deprecation_warning['GetChildren'] = deprecation_bool if fig is None: fig = plt.figure() @@ -1810,11 +1816,14 @@ def PlotLayer(layer, fig=None, nodecolor='b', nodesize=20): # 3D layer from mpl_toolkits.mplot3d import Axes3D - # Turn of deprecation warning as users shouldn't change implementation - # of PlotLayer, it is done by the developers + # Turn off _deprecation_warning as users shouldn't change + # implementation of PlotLayer, it is done by the developers + deprecation_bool = hlh._deprecation_warning['GetChildren'] hlh._deprecation_warning['GetChildren'] = False # extract position information, transpose to list of x,y,z positions pos = zip(*GetPosition(nest.GetChildren(layer)[0])) + # Need to reset the deprecation warning to its old value + hlh._deprecation_warning['GetChildren'] = deprecation_bool if fig is None: fig = plt.figure() From a779682c886fdca0210ed4e1a7aeb34c53327fe2 Mon Sep 17 00:00:00 2001 From: Stine Vennemo Date: Fri, 9 Dec 2016 10:29:04 +0100 Subject: [PATCH 04/16] Fixed formatting --- pynest/nest/lib/hl_api_subnets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pynest/nest/lib/hl_api_subnets.py b/pynest/nest/lib/hl_api_subnets.py index cb2170ae4b..eb44d11b73 100644 --- a/pynest/nest/lib/hl_api_subnets.py +++ b/pynest/nest/lib/hl_api_subnets.py @@ -301,8 +301,8 @@ def EndSubnet(): @check_stack -@deprecated('', 'LayoutNetwork is deprecated and will be removed in NEST3. Use \ -Create(, n=) instead.') +@deprecated('', 'LayoutNetwork is deprecated and will be removed in NEST3. \ +Use Create(, n=) instead.') def LayoutNetwork(model, dim, label=None, params=None): """Create a subnetwork of dimension dim with nodes of type model and return a list of ids. From 0cca6a1a41f0dcf3b637cae11252fab246124110 Mon Sep 17 00:00:00 2001 From: "Hans E. Plesser" Date: Mon, 12 Dec 2016 12:45:42 +0100 Subject: [PATCH 05/16] Neuron models can now be marked as deprecated in register_node_model() call. Subnet and iaf_neuron marked as deprecated for NEST 3.0. --- examples/MyModule/mymodule.cpp | 1 + models/modelsmodule.cpp | 6 +++- nest/neststartup.cpp | 1 + nestkernel/genericmodel.h | 31 +++++++++++++------- nestkernel/genericmodel_impl.h | 52 +++++++++++++++++++++++++++++++++ nestkernel/kernel_manager.h | 4 +-- nestkernel/model.h | 7 +++++ nestkernel/model_manager.cpp | 14 ++++++--- nestkernel/model_manager.h | 16 ++++++---- nestkernel/model_manager_impl.h | 11 ++++--- nestkernel/node_manager.cpp | 3 ++ precise/precisemodule.cpp | 1 + topology/topologymodule.cpp | 1 + 13 files changed, 119 insertions(+), 29 deletions(-) create mode 100644 nestkernel/genericmodel_impl.h diff --git a/examples/MyModule/mymodule.cpp b/examples/MyModule/mymodule.cpp index aa2696c036..3e51795cc9 100644 --- a/examples/MyModule/mymodule.cpp +++ b/examples/MyModule/mymodule.cpp @@ -36,6 +36,7 @@ #include "dynamicloader.h" #include "exceptions.h" #include "genericmodel.h" +#include "genericmodel_impl.h" #include "kernel_manager.h" #include "model.h" #include "model_manager_impl.h" diff --git a/models/modelsmodule.cpp b/models/modelsmodule.cpp index a986eb3f66..277ab1cbc7 100644 --- a/models/modelsmodule.cpp +++ b/models/modelsmodule.cpp @@ -36,6 +36,9 @@ #include "modelsmodule.h" +// Includes from nestkernel +#include "genericmodel_impl.h" + // Generated includes: #include "config.h" @@ -173,7 +176,8 @@ ModelsModule::commandstring( void ) const void ModelsModule::init( SLIInterpreter* ) { - kernel().model_manager.register_node_model< iaf_neuron >( "iaf_neuron" ); + kernel().model_manager.register_node_model< iaf_neuron >( "iaf_neuron", /* private_model */ false, + /* deprecation_info */ "NEST 3.0"); kernel().model_manager.register_node_model< iaf_chs_2007 >( "iaf_chs_2007" ); kernel().model_manager.register_node_model< iaf_psc_alpha >( "iaf_psc_alpha" ); diff --git a/nest/neststartup.cpp b/nest/neststartup.cpp index ea891fefe0..5a43d993b1 100644 --- a/nest/neststartup.cpp +++ b/nest/neststartup.cpp @@ -41,6 +41,7 @@ // Includes from nestkernel: #include "dynamicloader.h" +#include "genericmodel_impl.h" #include "kernel_manager.h" #include "nest.h" #include "nestmodule.h" diff --git a/nestkernel/genericmodel.h b/nestkernel/genericmodel.h index 39eda285fc..f291df2ba0 100644 --- a/nestkernel/genericmodel.h +++ b/nestkernel/genericmodel.h @@ -44,8 +44,8 @@ template < typename ElementT > class GenericModel : public Model { public: - GenericModel( const std::string& ); - GenericModel( const char[] ); + GenericModel( const std::string&, + const std::string& deprecation_info ); /** * Create copy of model with new name. @@ -85,6 +85,8 @@ class GenericModel : public Model void set_model_id( int ); + void deprecation_warning( const std::string& ); + private: void set_status_( DictionaryDatum ); DictionaryDatum get_status_(); @@ -105,20 +107,24 @@ class GenericModel : public Model * Prototype node from which all instances are constructed. */ ElementT proto_; + + /** + * String containing deprecation information; empty if model not deprecated. + */ + std::string deprecation_info_; + + /** + * False until deprecation warning has been issued once + */ + bool deprecation_warning_issued_; }; template < typename ElementT > -GenericModel< ElementT >::GenericModel( const std::string& name ) +GenericModel< ElementT >::GenericModel( const std::string& name, const std::string& deprecation_info ) : Model( name ) , proto_() -{ - set_threads(); -} - -template < typename ElementT > -GenericModel< ElementT >::GenericModel( const char name[] ) - : Model( std::string( name ) ) - , proto_() + , deprecation_info_( deprecation_info ) + , deprecation_warning_issued_( false ) { set_threads(); } @@ -128,6 +134,8 @@ GenericModel< ElementT >::GenericModel( const GenericModel& oldmod, const std::string& newname ) : Model( newname ) , proto_( oldmod.proto_ ) + , deprecation_info_( oldmod.deprecation_info_ ) + , deprecation_warning_issued_( false ) { set_type_id( oldmod.get_type_id() ); set_threads(); @@ -243,5 +251,6 @@ GenericModel< ElementT >::set_model_id( int i ) { proto_.set_model_id( i ); } + } #endif diff --git a/nestkernel/genericmodel_impl.h b/nestkernel/genericmodel_impl.h new file mode 100644 index 0000000000..ef3c04f7fb --- /dev/null +++ b/nestkernel/genericmodel_impl.h @@ -0,0 +1,52 @@ +/* + * genericmodel_impl.h + * + * This file is part of NEST. + * + * Copyright (C) 2004 The NEST Initiative + * + * NEST is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * NEST is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NEST. If not, see . + * + */ + +#ifndef GENERICMODEL_IMPL_H +#define GENERICMODEL_IMPL_H + +#include "genericmodel.h" + +// Includes from nestkernel: +#include "kernel_manager.h" +#include "logging_manager.h" + +namespace nest +{ + +template < typename ElementT > +void +GenericModel< ElementT >::deprecation_warning( const std::string& caller ) +{ + if ( deprecation_warning_issued_ or deprecation_info_.empty() ) + return; + + if ( not deprecation_info_.empty() ) + { + LOG( M_WARNING, caller, + "Model " + get_name() + " is deprecated in " + deprecation_info_ + "."); + } + + deprecation_warning_issued_ = true; +} + +} +#endif diff --git a/nestkernel/kernel_manager.h b/nestkernel/kernel_manager.h index ee8a4079a9..63cd94ea33 100644 --- a/nestkernel/kernel_manager.h +++ b/nestkernel/kernel_manager.h @@ -23,13 +23,11 @@ #ifndef KERNEL_MANAGER_H #define KERNEL_MANAGER_H -// Includes from libnestutil: -#include "logging_manager.h" - // Includes from nestkernel: #include "connection_manager.h" #include "event_delivery_manager.h" #include "io_manager.h" +#include "logging_manager.h" #include "model_manager.h" #include "modelrange_manager.h" #include "mpi_manager.h" diff --git a/nestkernel/model.h b/nestkernel/model.h index 088a43968e..c5c0628127 100644 --- a/nestkernel/model.h +++ b/nestkernel/model.h @@ -179,6 +179,13 @@ class Model */ virtual void set_model_id( int ) = 0; + /** + * Issue deprecation warning on first call if model is deprecated. + * + * @param calling function + */ + virtual void deprecation_warning( const std::string& ) = 0; + /** * Set the model id on the prototype. */ diff --git a/nestkernel/model_manager.cpp b/nestkernel/model_manager.cpp index 01900a0b62..838d28c80a 100644 --- a/nestkernel/model_manager.cpp +++ b/nestkernel/model_manager.cpp @@ -31,6 +31,7 @@ #include "compose.hpp" // Includes from nestkernel: +#include "genericmodel_impl.h" #include "kernel_manager.h" #include "model_manager_impl.h" #include "proxynode.h" @@ -84,18 +85,20 @@ ModelManager::initialize() // initialize these models only once outside of the constructor // as the node model asks for the # of threads to setup slipools // but during construction of ModelManager, the KernelManager is not created - subnet_model_ = new GenericModel< Subnet >( "subnet" ); + subnet_model_ = new GenericModel< Subnet >( "subnet", + /* deprecation_info */ "NEST 3.0" ); subnet_model_->set_type_id( 0 ); pristine_models_.push_back( std::pair< Model*, bool >( subnet_model_, false ) ); siblingcontainer_model_ = - new GenericModel< SiblingContainer >( "siblingcontainer" ); + new GenericModel< SiblingContainer >( std::string ( "siblingcontainer" ), + /* deprecation_info */ "" ); siblingcontainer_model_->set_type_id( 1 ); pristine_models_.push_back( std::pair< Model*, bool >( siblingcontainer_model_, true ) ); - proxynode_model_ = new GenericModel< proxynode >( "proxynode" ); + proxynode_model_ = new GenericModel< proxynode >( "proxynode", /* deprecation_info */ "" ); proxynode_model_->set_type_id( 2 ); pristine_models_.push_back( std::pair< Model*, bool >( proxynode_model_, true ) ); @@ -250,7 +253,10 @@ ModelManager::register_node_model_( Model* model, bool private_model ) index ModelManager::copy_node_model_( index old_id, Name new_name ) { - Model* new_model = get_model( old_id )->clone( new_name.toString() ); + Model* old_model = get_model( old_id ); + old_model->deprecation_warning( "CopyModel" ); + + Model* new_model = old_model->clone( new_name.toString() ); models_.push_back( new_model ); index new_id = models_.size() - 1; diff --git a/nestkernel/model_manager.h b/nestkernel/model_manager.h index 710b28fab0..2706c63ddf 100644 --- a/nestkernel/model_manager.h +++ b/nestkernel/model_manager.h @@ -26,13 +26,10 @@ // C++ includes: #include -// Includes from libnestutil: -#include "manager_interface.h" - // Includes from nestkernel: #include "connector_model.h" #include "genericmodel.h" -#include "genericmodel.h" +#include "manager_interface.h" #include "model.h" #include "nest_time.h" #include "nest_timeconverter.h" @@ -126,12 +123,15 @@ class ModelManager : public ManagerInterface * is in a *module.cpp file. * @param name of the new node model. * @param private_model if true, don't add model to modeldict. + * @param deprecation_info If non-empty string, deprecation warning will + * be issued for model with this info to user. * @return ID of the new model object. * @see register_private_prototype_model, register_preconf_node_model, * register_prototype_connection */ template < class ModelT > - index register_node_model( const Name& name, bool private_model = false ); + index register_node_model( const Name& name, bool private_model = false, + std::string deprecation_info = std::string() ); /** * Register a pre-configured model prototype with the network. @@ -146,6 +146,9 @@ class ModelManager : public ManagerInterface * @param name of the new node model. * @param private_model if true, don't add model to modeldict. * @param dictionary to use to pre-configure model + * @param deprecation_info If non-empty string, deprecation warning will + * be issued for model with this info to user. + * * @return ID of the new model object. * @see register_private_prototype_model, register_node_model, * register_prototype_connection @@ -153,7 +156,8 @@ class ModelManager : public ManagerInterface template < class ModelT > index register_preconf_node_model( const Name& name, DictionaryDatum& conf, - bool private_model = false ); + bool private_model = false, + std::string deprecation_info = std::string() ); /** * Copy an existing model and register it as a new model. diff --git a/nestkernel/model_manager_impl.h b/nestkernel/model_manager_impl.h index 50697d73be..163b4b6a0f 100644 --- a/nestkernel/model_manager_impl.h +++ b/nestkernel/model_manager_impl.h @@ -39,7 +39,8 @@ namespace nest template < class ModelT > index -ModelManager::register_node_model( const Name& name, bool private_model ) +ModelManager::register_node_model( const Name& name, bool private_model, + std::string deprecation_info ) { if ( !private_model && modeldict_->known( name ) ) { @@ -50,7 +51,8 @@ ModelManager::register_node_model( const Name& name, bool private_model ) throw NamingConflict( msg ); } - Model* model = new GenericModel< ModelT >( name.toString() ); + Model* model = new GenericModel< ModelT >( name.toString(), + deprecation_info ); return register_node_model_( model, private_model ); } @@ -58,7 +60,7 @@ template < class ModelT > index ModelManager::register_preconf_node_model( const Name& name, DictionaryDatum& conf, - bool private_model ) + bool private_model, std::string deprecation_info ) { if ( !private_model && modeldict_->known( name ) ) { @@ -69,7 +71,8 @@ ModelManager::register_preconf_node_model( const Name& name, throw NamingConflict( msg ); } - Model* model = new GenericModel< ModelT >( name.toString() ); + Model* model = new GenericModel< ModelT >( name.toString(), + deprecation_info ); conf->clear_access_flags(); model->set_status( conf ); std::string missed; diff --git a/nestkernel/node_manager.cpp b/nestkernel/node_manager.cpp index 2b5e7053bc..442c0b2902 100644 --- a/nestkernel/node_manager.cpp +++ b/nestkernel/node_manager.cpp @@ -32,6 +32,7 @@ // Includes from nestkernel: #include "event_delivery_manager.h" #include "genericmodel.h" +#include "genericmodel_impl.h" #include "kernel_manager.h" #include "model.h" #include "model_manager_impl.h" @@ -201,6 +202,8 @@ index NodeManager::add_node( index mod, long n ) // no_p Model* model = kernel().model_manager.get_model( mod ); assert( model != 0 ); + model->deprecation_warning( "Create" ); + /* current_ points to the instance of the current subnet on thread 0. The following code makes subnet a pointer to the wrapper container containing the instances of the current subnet on all threads. diff --git a/precise/precisemodule.cpp b/precise/precisemodule.cpp index f143b6df03..e50297bdcb 100644 --- a/precise/precisemodule.cpp +++ b/precise/precisemodule.cpp @@ -42,6 +42,7 @@ // Includes from nestkernel: #include "genericmodel.h" +#include "genericmodel_impl.h" #include "kernel_manager.h" #include "model.h" #include "model_manager_impl.h" diff --git a/topology/topologymodule.cpp b/topology/topologymodule.cpp index da8147494e..a58f55eac3 100644 --- a/topology/topologymodule.cpp +++ b/topology/topologymodule.cpp @@ -27,6 +27,7 @@ // Includes from nestkernel: #include "genericmodel.h" +#include "genericmodel_impl.h" #include "kernel_manager.h" #include "model.h" #include "model_manager_impl.h" From 2b456e253e5d0033718bdcdef022eb9911e5b2ca Mon Sep 17 00:00:00 2001 From: "Hans E. Plesser" Date: Mon, 12 Dec 2016 13:41:56 +0100 Subject: [PATCH 06/16] Added support for marking SLI functions as deprecated. --- nestkernel/nestmodule.cpp | 2 +- sli/datum.h | 2 +- sli/functiondatum.h | 26 +++++++++++++++++++++++++- sli/interpret.cc | 37 +++++-------------------------------- sli/interpret.h | 4 ++-- 5 files changed, 34 insertions(+), 37 deletions(-) diff --git a/nestkernel/nestmodule.cpp b/nestkernel/nestmodule.cpp index 699dd20609..d4c6735212 100644 --- a/nestkernel/nestmodule.cpp +++ b/nestkernel/nestmodule.cpp @@ -1614,7 +1614,7 @@ NestModule::init( SLIInterpreter* i ) // register interface functions with interpreter i->createcommand( "ChangeSubnet", &changesubnet_ifunction ); - i->createcommand( "CurrentSubnet", ¤tsubnetfunction ); + i->createcommand( "CurrentSubnet", ¤tsubnetfunction, "NEST 3.0" ); i->createcommand( "GetNodes_i_D_b_b", &getnodes_i_D_b_bfunction ); i->createcommand( "GetLeaves_i_D_b", &getleaves_i_D_bfunction ); i->createcommand( "GetChildren_i_D_b", &getchildren_i_D_bfunction ); diff --git a/sli/datum.h b/sli/datum.h index 9e8c2a65dd..217847151a 100644 --- a/sli/datum.h +++ b/sli/datum.h @@ -175,7 +175,7 @@ class Datum return ( type == &t ); } - void + virtual void execute( SLIInterpreter* i ) { action->execute( i ); diff --git a/sli/functiondatum.h b/sli/functiondatum.h index 0a52913c59..2f665b0668 100644 --- a/sli/functiondatum.h +++ b/sli/functiondatum.h @@ -49,6 +49,12 @@ class FunctionDatum : public TypedDatum< &SLIInterpreter::Functiontype > Name name; + /** If not empty string, it should contain string with version for which + * feature is deprecated. + */ + std::string deprecation_info_; + bool deprecation_warning_issued_; + Datum* clone( void ) const { @@ -75,13 +81,18 @@ class FunctionDatum : public TypedDatum< &SLIInterpreter::Functiontype > FunctionDatum( FunctionDatum const& fd ) : TypedDatum< &SLIInterpreter::Functiontype >( fd ) , name( fd.name ) + , deprecation_info_( fd.deprecation_info_ ) + , deprecation_warning_issued_( false ) { set_executable(); } - FunctionDatum( Name const& n, SLIFunction const* f ) + FunctionDatum( Name const& n, SLIFunction const* f, + const std::string& deprecation_info ) : TypedDatum< &SLIInterpreter::Functiontype >() , name( n ) + , deprecation_info_( deprecation_info ) + , deprecation_warning_issued_( false ) { //! Here, we shortcut the default action of the type object and directly //! place the function pointer in the datum's action field. Thus, we @@ -90,6 +101,19 @@ class FunctionDatum : public TypedDatum< &SLIInterpreter::Functiontype > set_executable(); } + void + execute( SLIInterpreter* i ) + { + if ( not ( deprecation_warning_issued_ or deprecation_info_.empty() ) ) + { + i->message( SLIInterpreter::M_WARNING, "SLIInterpreter", + ("SLI function " + name.toString() + " is deprecated in " + + deprecation_info_ + ".").c_str()); + deprecation_warning_issued_ = true; + } + + action->execute( i ); + } void print( std::ostream& o ) const diff --git a/sli/interpret.cc b/sli/interpret.cc index f805935d3e..e73f967a8f 100644 --- a/sli/interpret.cc +++ b/sli/interpret.cc @@ -255,13 +255,13 @@ SLIInterpreter::initexternals( void ) FunctionDatum* SLIInterpreter::Ilookup( void ) const { - return new FunctionDatum( ilookup_name, &SLIInterpreter::ilookupfunction ); + return new FunctionDatum( ilookup_name, &SLIInterpreter::ilookupfunction, "" ); } FunctionDatum* SLIInterpreter::Iiterate( void ) const { - return new FunctionDatum( iiterate_name, &SLIInterpreter::iiteratefunction ); + return new FunctionDatum( iiterate_name, &SLIInterpreter::iiteratefunction, "" ); } void @@ -279,14 +279,15 @@ SLIInterpreter::createdouble( Name const& n, double d ) * exists. */ void -SLIInterpreter::createcommand( Name const& n, SLIFunction const* fn ) +SLIInterpreter::createcommand( Name const& n, SLIFunction const* fn, + std::string deprecation_info ) { if ( DStack->known( n ) ) throw NamingConflict("A function called '" + std::string(n.toString()) + "' exists already.\n" "Please choose a different name!"); - Token t( new FunctionDatum( n, fn ) ); + Token t( new FunctionDatum( n, fn, deprecation_info ) ); DStack->def_move( n, t ); } @@ -304,34 +305,6 @@ SLIInterpreter::createconstant( Name const& n, Token const& val ) DStack->def_move( n, t ); } -/** Define a function inside a "namespace" (bottom level dictionary). - * This function may be used to group SLI commands in some kind of - * "name spaces" that are implemented using dictionaries. - * It defines the SLI function inside a dictionary of - * the given Name, which is known in systemdict. - * If a dictionary of the given Name is not yet known inside - * systemdict, it is created. - * Note that you may also pass strings as the first arguments, as - * there is an implicit type conversion operator from string to Name. - * Use the Name when name objects already exist. - */ -void -SLIInterpreter::createcommand( Name const& dictn, - Name const& n, - SLIFunction const* fn ) -{ - if ( !( baseknown( dictn ) ) ) - { - Dictionary* d = new Dictionary; // get a new dictionary from the heap - basedef( dictn, new DictionaryDatum( d ) ); - } - Token dt = baselookup( dictn ); - DictionaryDatum* dd = dynamic_cast< DictionaryDatum* >( dt.datum() ); - DStack->push( *dd ); - createcommand( n, fn ); - DStack->pop(); -} - const Token& SLIInterpreter::lookup( const Name& n ) const { diff --git a/sli/interpret.h b/sli/interpret.h index 8db52112b3..a190fbea0b 100644 --- a/sli/interpret.h +++ b/sli/interpret.h @@ -279,8 +279,8 @@ class SLIInterpreter int execute_debug_( size_t exitlevel = 0 ); void createdouble( Name const&, double ); - void createcommand( Name const&, SLIFunction const* ); - void createcommand( Name const&, Name const&, SLIFunction const* ); + void createcommand( Name const&, SLIFunction const*, + std::string deprecation_info = std::string() ); void createconstant( Name const&, const Token& ); From e3ffe9b8abf14c41fa49224658f4346edba7829e Mon Sep 17 00:00:00 2001 From: "Hans E. Plesser" Date: Mon, 12 Dec 2016 13:44:55 +0100 Subject: [PATCH 07/16] Fixed formatting. --- models/modelsmodule.cpp | 5 +++-- nestkernel/genericmodel.h | 7 +++---- nestkernel/genericmodel_impl.h | 10 +++++----- nestkernel/model_manager.cpp | 9 +++++---- nestkernel/model_manager.h | 7 ++++--- nestkernel/model_manager_impl.h | 16 +++++++++------- sli/functiondatum.h | 28 +++++++++++++++------------- sli/interpret.cc | 11 +++++++---- sli/interpret.h | 5 +++-- 9 files changed, 54 insertions(+), 44 deletions(-) diff --git a/models/modelsmodule.cpp b/models/modelsmodule.cpp index 277ab1cbc7..fab77a962f 100644 --- a/models/modelsmodule.cpp +++ b/models/modelsmodule.cpp @@ -176,8 +176,9 @@ ModelsModule::commandstring( void ) const void ModelsModule::init( SLIInterpreter* ) { - kernel().model_manager.register_node_model< iaf_neuron >( "iaf_neuron", /* private_model */ false, - /* deprecation_info */ "NEST 3.0"); + kernel().model_manager.register_node_model< iaf_neuron >( "iaf_neuron", + /* private_model */ false, + /* deprecation_info */ "NEST 3.0" ); kernel().model_manager.register_node_model< iaf_chs_2007 >( "iaf_chs_2007" ); kernel().model_manager.register_node_model< iaf_psc_alpha >( "iaf_psc_alpha" ); diff --git a/nestkernel/genericmodel.h b/nestkernel/genericmodel.h index f291df2ba0..9dd0437268 100644 --- a/nestkernel/genericmodel.h +++ b/nestkernel/genericmodel.h @@ -44,8 +44,7 @@ template < typename ElementT > class GenericModel : public Model { public: - GenericModel( const std::string&, - const std::string& deprecation_info ); + GenericModel( const std::string&, const std::string& deprecation_info ); /** * Create copy of model with new name. @@ -120,7 +119,8 @@ class GenericModel : public Model }; template < typename ElementT > -GenericModel< ElementT >::GenericModel( const std::string& name, const std::string& deprecation_info ) +GenericModel< ElementT >::GenericModel( const std::string& name, + const std::string& deprecation_info ) : Model( name ) , proto_() , deprecation_info_( deprecation_info ) @@ -251,6 +251,5 @@ GenericModel< ElementT >::set_model_id( int i ) { proto_.set_model_id( i ); } - } #endif diff --git a/nestkernel/genericmodel_impl.h b/nestkernel/genericmodel_impl.h index ef3c04f7fb..d23ad94726 100644 --- a/nestkernel/genericmodel_impl.h +++ b/nestkernel/genericmodel_impl.h @@ -36,17 +36,17 @@ template < typename ElementT > void GenericModel< ElementT >::deprecation_warning( const std::string& caller ) { - if ( deprecation_warning_issued_ or deprecation_info_.empty() ) - return; + if ( deprecation_warning_issued_ or deprecation_info_.empty() ) + return; if ( not deprecation_info_.empty() ) { - LOG( M_WARNING, caller, - "Model " + get_name() + " is deprecated in " + deprecation_info_ + "."); + LOG( M_WARNING, + caller, + "Model " + get_name() + " is deprecated in " + deprecation_info_ + "." ); } deprecation_warning_issued_ = true; } - } #endif diff --git a/nestkernel/model_manager.cpp b/nestkernel/model_manager.cpp index 838d28c80a..267a438c60 100644 --- a/nestkernel/model_manager.cpp +++ b/nestkernel/model_manager.cpp @@ -86,19 +86,20 @@ ModelManager::initialize() // as the node model asks for the # of threads to setup slipools // but during construction of ModelManager, the KernelManager is not created subnet_model_ = new GenericModel< Subnet >( "subnet", - /* deprecation_info */ "NEST 3.0" ); + /* deprecation_info */ "NEST 3.0" ); subnet_model_->set_type_id( 0 ); pristine_models_.push_back( std::pair< Model*, bool >( subnet_model_, false ) ); siblingcontainer_model_ = - new GenericModel< SiblingContainer >( std::string ( "siblingcontainer" ), - /* deprecation_info */ "" ); + new GenericModel< SiblingContainer >( std::string( "siblingcontainer" ), + /* deprecation_info */ "" ); siblingcontainer_model_->set_type_id( 1 ); pristine_models_.push_back( std::pair< Model*, bool >( siblingcontainer_model_, true ) ); - proxynode_model_ = new GenericModel< proxynode >( "proxynode", /* deprecation_info */ "" ); + proxynode_model_ = + new GenericModel< proxynode >( "proxynode", /* deprecation_info */ "" ); proxynode_model_->set_type_id( 2 ); pristine_models_.push_back( std::pair< Model*, bool >( proxynode_model_, true ) ); diff --git a/nestkernel/model_manager.h b/nestkernel/model_manager.h index 2706c63ddf..62a765de59 100644 --- a/nestkernel/model_manager.h +++ b/nestkernel/model_manager.h @@ -130,8 +130,9 @@ class ModelManager : public ManagerInterface * register_prototype_connection */ template < class ModelT > - index register_node_model( const Name& name, bool private_model = false, - std::string deprecation_info = std::string() ); + index register_node_model( const Name& name, + bool private_model = false, + std::string deprecation_info = std::string() ); /** * Register a pre-configured model prototype with the network. @@ -157,7 +158,7 @@ class ModelManager : public ManagerInterface index register_preconf_node_model( const Name& name, DictionaryDatum& conf, bool private_model = false, - std::string deprecation_info = std::string() ); + std::string deprecation_info = std::string() ); /** * Copy an existing model and register it as a new model. diff --git a/nestkernel/model_manager_impl.h b/nestkernel/model_manager_impl.h index 163b4b6a0f..ce46b0d9dc 100644 --- a/nestkernel/model_manager_impl.h +++ b/nestkernel/model_manager_impl.h @@ -39,8 +39,9 @@ namespace nest template < class ModelT > index -ModelManager::register_node_model( const Name& name, bool private_model, - std::string deprecation_info ) +ModelManager::register_node_model( const Name& name, + bool private_model, + std::string deprecation_info ) { if ( !private_model && modeldict_->known( name ) ) { @@ -51,8 +52,8 @@ ModelManager::register_node_model( const Name& name, bool private_model, throw NamingConflict( msg ); } - Model* model = new GenericModel< ModelT >( name.toString(), - deprecation_info ); + Model* model = + new GenericModel< ModelT >( name.toString(), deprecation_info ); return register_node_model_( model, private_model ); } @@ -60,7 +61,8 @@ template < class ModelT > index ModelManager::register_preconf_node_model( const Name& name, DictionaryDatum& conf, - bool private_model, std::string deprecation_info ) + bool private_model, + std::string deprecation_info ) { if ( !private_model && modeldict_->known( name ) ) { @@ -71,8 +73,8 @@ ModelManager::register_preconf_node_model( const Name& name, throw NamingConflict( msg ); } - Model* model = new GenericModel< ModelT >( name.toString(), - deprecation_info ); + Model* model = + new GenericModel< ModelT >( name.toString(), deprecation_info ); conf->clear_access_flags(); model->set_status( conf ); std::string missed; diff --git a/sli/functiondatum.h b/sli/functiondatum.h index 2f665b0668..0a7c43e917 100644 --- a/sli/functiondatum.h +++ b/sli/functiondatum.h @@ -81,18 +81,19 @@ class FunctionDatum : public TypedDatum< &SLIInterpreter::Functiontype > FunctionDatum( FunctionDatum const& fd ) : TypedDatum< &SLIInterpreter::Functiontype >( fd ) , name( fd.name ) - , deprecation_info_( fd.deprecation_info_ ) - , deprecation_warning_issued_( false ) + , deprecation_info_( fd.deprecation_info_ ) + , deprecation_warning_issued_( false ) { set_executable(); } - FunctionDatum( Name const& n, SLIFunction const* f, - const std::string& deprecation_info ) + FunctionDatum( Name const& n, + SLIFunction const* f, + const std::string& deprecation_info ) : TypedDatum< &SLIInterpreter::Functiontype >() , name( n ) - , deprecation_info_( deprecation_info ) - , deprecation_warning_issued_( false ) + , deprecation_info_( deprecation_info ) + , deprecation_warning_issued_( false ) { //! Here, we shortcut the default action of the type object and directly //! place the function pointer in the datum's action field. Thus, we @@ -104,13 +105,14 @@ class FunctionDatum : public TypedDatum< &SLIInterpreter::Functiontype > void execute( SLIInterpreter* i ) { - if ( not ( deprecation_warning_issued_ or deprecation_info_.empty() ) ) - { - i->message( SLIInterpreter::M_WARNING, "SLIInterpreter", - ("SLI function " + name.toString() + " is deprecated in " - + deprecation_info_ + ".").c_str()); - deprecation_warning_issued_ = true; - } + if ( not( deprecation_warning_issued_ or deprecation_info_.empty() ) ) + { + i->message( SLIInterpreter::M_WARNING, + "SLIInterpreter", + ( "SLI function " + name.toString() + " is deprecated in " + + deprecation_info_ + "." ).c_str() ); + deprecation_warning_issued_ = true; + } action->execute( i ); } diff --git a/sli/interpret.cc b/sli/interpret.cc index e73f967a8f..64acef6d01 100644 --- a/sli/interpret.cc +++ b/sli/interpret.cc @@ -255,13 +255,15 @@ SLIInterpreter::initexternals( void ) FunctionDatum* SLIInterpreter::Ilookup( void ) const { - return new FunctionDatum( ilookup_name, &SLIInterpreter::ilookupfunction, "" ); + return new FunctionDatum( + ilookup_name, &SLIInterpreter::ilookupfunction, "" ); } FunctionDatum* SLIInterpreter::Iiterate( void ) const { - return new FunctionDatum( iiterate_name, &SLIInterpreter::iiteratefunction, "" ); + return new FunctionDatum( + iiterate_name, &SLIInterpreter::iiteratefunction, "" ); } void @@ -279,8 +281,9 @@ SLIInterpreter::createdouble( Name const& n, double d ) * exists. */ void -SLIInterpreter::createcommand( Name const& n, SLIFunction const* fn, - std::string deprecation_info ) +SLIInterpreter::createcommand( Name const& n, + SLIFunction const* fn, + std::string deprecation_info ) { if ( DStack->known( n ) ) throw NamingConflict("A function called '" + std::string(n.toString()) diff --git a/sli/interpret.h b/sli/interpret.h index a190fbea0b..f6e5b40188 100644 --- a/sli/interpret.h +++ b/sli/interpret.h @@ -279,8 +279,9 @@ class SLIInterpreter int execute_debug_( size_t exitlevel = 0 ); void createdouble( Name const&, double ); - void createcommand( Name const&, SLIFunction const*, - std::string deprecation_info = std::string() ); + void createcommand( Name const&, + SLIFunction const*, + std::string deprecation_info = std::string() ); void createconstant( Name const&, const Token& ); From 3c18a1a61406c85da00cf503650d7bee7da7e27b Mon Sep 17 00:00:00 2001 From: Stine Vennemo Date: Tue, 13 Dec 2016 16:13:48 +0100 Subject: [PATCH 08/16] Updated sli deprecation, changed iaf_neuron to iaf_cond_alpha in PyNEST examples, made sure deprecation warnings are issued when CreateLayer is used. --- lib/sli/nest-init.sli | 19 ++ models/modelsmodule.cpp | 3 +- nestkernel/nestmodule.cpp | 12 +- pynest/examples/balancedneuron.py | 4 +- pynest/examples/csa_example.py | 4 +- pynest/examples/csa_topology_example.py | 12 +- .../examples/evaluate_aeif_cond_alpha_RK5.py | 186 ------------------ pynest/examples/one_neuron.py | 2 +- pynest/examples/one_neuron_with_noise.py | 2 +- pynest/examples/structural_plasticity.py | 4 +- pynest/examples/testiaf.py | 2 +- pynest/examples/twoneurons.py | 4 +- pynest/nest/lib/hl_api_connections.py | 10 + pynest/nest/lib/hl_api_helper.py | 3 +- pynest/nest/lib/hl_api_nodes.py | 2 +- pynest/nest/lib/hl_api_subnets.py | 20 +- topology/examples/conncomp.py | 4 +- topology/examples/conncon_sources.py | 4 +- topology/examples/conncon_targets.py | 4 +- topology/examples/connex.py | 4 +- topology/examples/connex_ew.py | 4 +- topology/examples/ctx_2n.py | 4 +- topology/examples/gaussex.py | 4 +- topology/examples/grid_iaf.py | 2 +- topology/examples/grid_iaf_irr.py | 2 +- topology/examples/grid_iaf_oc.py | 2 +- topology/examples/test_3d.py | 2 +- topology/examples/test_3d_exp.py | 2 +- topology/examples/test_3d_gauss.py | 2 +- topology/pynest/hl_api.py | 8 + 30 files changed, 97 insertions(+), 240 deletions(-) delete mode 100644 pynest/examples/evaluate_aeif_cond_alpha_RK5.py diff --git a/lib/sli/nest-init.sli b/lib/sli/nest-init.sli index a238f7acd0..181bb17ca8 100644 --- a/lib/sli/nest-init.sli +++ b/lib/sli/nest-init.sli @@ -732,9 +732,16 @@ def SeeAlso: Create, LayoutArray */ +true /first_deprecation_warning Set + /LayoutNetwork_l_a_dict { << >> begin + first_deprecation_warning true eq + { + (Sli function LayoutNetwork is deprecated in NEST 3.0.) M_WARNING message + false /first_deprecation_warning Set + } if /val Set size /n_dim Set dup 0 get /n Set @@ -775,6 +782,11 @@ def /LayoutNetwork_l_a { << >> begin + first_deprecation_warning true eq + { + (Sli function LayoutNetwork is deprecated in NEST 3.0.) M_WARNING message + false /first_deprecation_warning Set + } if size /n_dim Set dup 0 get /n Set /dim Set @@ -1222,8 +1234,15 @@ def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +true /first_deprecation_warning Set + /GetNetwork_i_i { << >> begin + first_deprecation_warning true eq + { + (Sli function GetNetwork is deprecated in NEST 3.0.) M_WARNING message + false /first_deprecation_warning Set + } if /depth Set dup GetStatus /model get % id model diff --git a/models/modelsmodule.cpp b/models/modelsmodule.cpp index fab77a962f..718845cbc5 100644 --- a/models/modelsmodule.cpp +++ b/models/modelsmodule.cpp @@ -358,7 +358,8 @@ ModelsModule::init( SLIInterpreter* ) #endif // This version of the AdEx model does not depend on GSL. kernel().model_manager.register_node_model< aeif_cond_alpha_RK5 >( - "aeif_cond_alpha_RK5" ); + "aeif_cond_alpha_RK5", /*private_model*/ false, + /*deprecation_model*/ "NEST 3.0" ); kernel().model_manager.register_node_model< aeif_cond_alpha_multisynapse >( "aeif_cond_alpha_multisynapse" ); diff --git a/nestkernel/nestmodule.cpp b/nestkernel/nestmodule.cpp index d4c6735212..61579518f0 100644 --- a/nestkernel/nestmodule.cpp +++ b/nestkernel/nestmodule.cpp @@ -1613,11 +1613,11 @@ NestModule::init( SLIInterpreter* i ) GIDCollectionType.setdefaultaction( SLIInterpreter::datatypefunction ); // register interface functions with interpreter - i->createcommand( "ChangeSubnet", &changesubnet_ifunction ); + i->createcommand( "ChangeSubnet", &changesubnet_ifunction, "NEST 3.0" ); i->createcommand( "CurrentSubnet", ¤tsubnetfunction, "NEST 3.0" ); - i->createcommand( "GetNodes_i_D_b_b", &getnodes_i_D_b_bfunction ); - i->createcommand( "GetLeaves_i_D_b", &getleaves_i_D_bfunction ); - i->createcommand( "GetChildren_i_D_b", &getchildren_i_D_bfunction ); + i->createcommand( "GetNodes_i_D_b_b", &getnodes_i_D_b_bfunction, "NEST 3.0" ); + i->createcommand( "GetLeaves_i_D_b", &getleaves_i_D_bfunction, "NEST 3.0" ); + i->createcommand( "GetChildren_i_D_b", &getchildren_i_D_bfunction, "NEST 3.0" ); i->createcommand( "RestoreNodes_a", &restorenodes_afunction ); @@ -1642,8 +1642,8 @@ NestModule::init( SLIInterpreter* i ) i->createcommand( "Connect_g_g_D_D", &connect_g_g_D_Dfunction ); - i->createcommand( "DataConnect_i_D_s", &dataconnect_i_D_sfunction ); - i->createcommand( "DataConnect_a", &dataconnect_afunction ); + i->createcommand( "DataConnect_i_D_s", &dataconnect_i_D_sfunction, "NEST 3.0" ); + i->createcommand( "DataConnect_a", &dataconnect_afunction, "NEST 3.0" ); i->createcommand( "ResetNetwork", &resetnetworkfunction ); i->createcommand( "ResetKernel", &resetkernelfunction ); diff --git a/pynest/examples/balancedneuron.py b/pynest/examples/balancedneuron.py index 5ec7418fd3..e0fef62535 100644 --- a/pynest/examples/balancedneuron.py +++ b/pynest/examples/balancedneuron.py @@ -75,7 +75,7 @@ handles in variables for later reference. ''' -neuron = nest.Create("iaf_neuron") +neuron = nest.Create("iaf_psc_alpha") noise = nest.Create("poisson_generator", 2) voltmeter = nest.Create("voltmeter") spikedetector = nest.Create("spike_detector") @@ -93,7 +93,7 @@ nest.SetStatus(voltmeter, {"withgid": True, "withtime": True}) ''' -Fifth, the `iaf_neuron` is connected to the `spike_detector` and the +Fifth, the `iaf_psc_alpha` is connected to the `spike_detector` and the `voltmeter`, as are the two Poisson generators to the neuron. The command `Connect` has different variants. Plain `Connect` just takes the handles of pre- and post-synaptic nodes and uses the default diff --git a/pynest/examples/csa_example.py b/pynest/examples/csa_example.py index 39b1e1073e..243d97baf1 100644 --- a/pynest/examples/csa_example.py +++ b/pynest/examples/csa_example.py @@ -73,8 +73,8 @@ neurons. """ -pre = nest.Create("iaf_neuron", 16) -post = nest.Create("iaf_neuron", 16) +pre = nest.Create("iaf_psc_alpha", 16) +post = nest.Create("iaf_psc_alpha", 16) """ We can now connect the populations using the `CGConnect` function. diff --git a/pynest/examples/csa_topology_example.py b/pynest/examples/csa_topology_example.py index 34fe6597fb..71117d2499 100644 --- a/pynest/examples/csa_topology_example.py +++ b/pynest/examples/csa_topology_example.py @@ -80,12 +80,12 @@ def geometry_function(idx): return geometry_function """ -We create two layers that have 20x20 neurons of type `iaf_neuron`. +We create two layers that have 20x20 neurons of type `iaf_psc_alpha`. """ -pop1 = topo.CreateLayer({'elements': 'iaf_neuron', +pop1 = topo.CreateLayer({'elements': 'iaf_psc_alpha', 'rows': 20, 'columns': 20}) -pop2 = topo.CreateLayer({'elements': 'iaf_neuron', +pop2 = topo.CreateLayer({'elements': 'iaf_psc_alpha', 'rows': 20, 'columns': 20}) """ @@ -113,7 +113,11 @@ def geometry_function(idx): associated with the connection set. """ -nest.CGConnect(pop1, pop2, cs, {"weight": 0, "delay": 1}) +# Find the gids to use in CGConnect, this is a work-around until NEST 3.0. +pop1_gids = nest.GetLeaves(pop1) +pop2_gids = nest.GetLeaves(pop2) + +nest.CGConnect(pop1_gids[0], pop2_gids[0], cs, {"weight": 0, "delay": 1}) """ Finally, we use the `PlotTargets` function to show all targets in diff --git a/pynest/examples/evaluate_aeif_cond_alpha_RK5.py b/pynest/examples/evaluate_aeif_cond_alpha_RK5.py deleted file mode 100644 index 29e4fb54aa..0000000000 --- a/pynest/examples/evaluate_aeif_cond_alpha_RK5.py +++ /dev/null @@ -1,186 +0,0 @@ -# -*- coding: utf-8 -*- -# -# evaluate_aeif_cond_alpha_RK5.py -# -# This file is part of NEST. -# -# Copyright (C) 2004 The NEST Initiative -# -# NEST is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# NEST is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with NEST. If not, see . - -# Test script for new implementation of AdEx numerics. -# Stefan BUCHER (web@stefan-bucher.ch), July 2013. - -import nest -import numpy as np -import timeit - -""" -Example of the Adaptive Exponential Integrate and Fire (AdEx) in NEST. ----------------------------------------------------------------------- - -This script compares the two aeif_cond_alpha flavors with respect to speed -and precision. - -Version 1 is the GSL based 'aeif_cond_alpha' model. -Version 2 is called 'aeif_cond_alpha_RK5' which uses an explicitly coded -version of the RK-45 method as described in Numerical Recepies, Chap. 17.2, -Press et al (2007). - -Reference is Version 1 at a temporal resolution of 0.001 ms. - -The test comparest both versions at a resolution of 0.1 ms with the reference. -Two errors are computed: -1. the difference is spike times wrt reference -2. the L2 (root mean squared) error of the voltage response - to a step current input. - -aeif_cond_alpha_RK5 is the adaptive exponential integrate-and-fire neuron -according to Brette and Gerstner (2005). Synaptic conductances are modelled -as alpha-functions. - -This implementation uses a 5th order Runge-Kutta solver with adaptive stepsize -to integrate the differential equation (see Numerical Recipes 3rd Edition, -Press et al. 2007, Ch. 17.2). - -The membrane potential is given by the following differential equation: - - C dV/dt = - g_L (V-E_L) + g_L Delta_T exp((V-V_T)/Delta_T) - - g_e(t) (V-E_e) - g_i(t) (V-E_i) - w + I_e - -and - - tau_w dw/dt = a (V-E_L) - w - -Parameters: -The following parameters can be set in the status dictionary. - -Dynamic state variables: - V_m double - Membrane potential in mV - g_ex double - Excitatory synaptic conductance in nS. - dg_ex double - First derivative of g_ex in nS/ms - g_in double - Inhibitory synaptic conductance in nS. - dg_in double - First derivative of g_in in nS/ms. - w double - Spike-adaptation current in pA. - -Membrane Parameters: - C_m double - Capacity of the membrane in pF - t_ref double - Duration of refractory period in ms. - V_reset double - Reset value for V_m after a spike. In mV. - E_L double - Leak reversal potential in mV. - g_L double - Leak conductance in nS. - I_e double - Constant external input current in pA. - -Spike adaptation parameters: - a double - Subthreshold adaptation in nS. - b double - Spike-triggered adaptation in pA. - Delta_T double - Slope factor in mV - tau_w double - Adaptation time constant in ms - V_th double - Spike initiation threshold in mV - V_peak double - Spike detection threshold in mV. - -Synaptic parameters: - E_ex double - Excitatory reversal potential in mV. - tau_syn_ex double - Rise time of excitatory synaptic conductance - in ms (alpha function). - E_in double - Inhibitory reversal potential in mV. - tau_syn_in double - Rise time of the inhibitory synaptic conductance - in ms (alpha function). - -Numerical integration parameters: - HMIN double - Minimal stepsize for numerical integration - in ms (default 0.001ms). - MAXERR double - Error estimate tolerance for adaptive stepsize control - (steps accepted if err<=MAXERR). In mV. Note that the - error refers to the difference between the 4th and 5th - order RK terms. Default 1e-10 mV. -""" - - -def run_model(model='aeif_cond_alpha', dt=0.1, reps=1): - ''' - Helper function to run a standard protocol with a neuron of model `model. - The parameters specify the resolution and number of repetitions. - ''' - nest.ResetKernel() - nest.sr("30 setverbosity") - nest.SetKernelStatus({"overwrite_files": True}) - nest.SetStatus([0], [{"resolution": dt}]) - nest.SetDefaults('aeif_cond_alpha_RK5', {'HMIN': 0.001}) - nest.SetDefaults('aeif_cond_alpha_RK5', {'MAXERR': 1e-10}) - - neuron = nest.Create(model, 2) - nest.SetStatus(neuron, [{"V_peak": 0.0, "a": 4.0, "b": 80.5}]) - - dc = nest.Create("dc_generator") - nest.SetStatus(dc, [{"amplitude": 700.0, - "start": 700.0, - "stop": 2700.0}]) - nest.Connect(dc, [neuron[0]]) - - sd = nest.Create('spike_detector') - nest.Connect([neuron[0]], sd) - - meter0 = nest.Create('multimeter', - params={'record_from': ['V_m', 'g_ex', 'g_in', 'w'], - 'interval': 0.1}) - nest.Connect(meter0, [neuron[0]]) - nest.SetStatus(meter0, [{"to_file": False, "withtime": True}]) - - t = timeit.Timer("nest.Simulate(3000)", "import nest") - runtime = t.timeit(number=reps) / reps - sptimes = nest.GetStatus(sd, "events")[0]['times'] - voltage_trace = nest.GetStatus(meter0, "events")[0]['V_m'] - return (runtime, sptimes, voltage_trace) - -''' -Now we run the different simulations. -Three traces a produced. First, a reference trace of the original -`aeif_cond_alpha model with 100 times higher resolution than the default. -The second trace is from the `aeif_cond_alpha model with default resolution -and the final trace is from the `aeif_cond_alphaRK5 model also at default -resolution. -''' - -reference = run_model(model='aeif_cond_alpha', dt=0.001, reps=50) -gsl = run_model(model='aeif_cond_alpha', dt=0.1, reps=50) -test = run_model(model='aeif_cond_alpha_RK5', dt=0.1, reps=50) - -''' -Compare the execution times of the models. -''' - -print 'Runtime GSL: ' + str(gsl[0]) -print 'Test: ' + str(test[0]) -print 'Ratio: ' + str(test[0] / gsl[0]) - -''' -Compute the error on the spike times. -''' -print 'Spike Times GSL - Reference:' + str(np.array(gsl[1]) - - np.array(reference[1])) -print 'Spike Times Test - Reference: ' + str(np.array(test[1]) - - np.array(reference[1])) - -''' -Also compare the L2-Norm of Voltage Traces -''' - -print ('L2-Error (per s) GSL - Reference: ' + - str(np.linalg.norm(gsl[2] - reference[2], ord=2) / 3)) -print ('L2-Error (per s) Test - Reference: ' + - str(np.linalg.norm(test[2] - reference[2], ord=2) / 3)) -print ('L2-Error ratio: ' + - str((np.linalg.norm(test[2] - reference[2], ord=2) / 3) / - (np.linalg.norm(gsl[2] - reference[2], ord=2) / 3))) diff --git a/pynest/examples/one_neuron.py b/pynest/examples/one_neuron.py index d22bd8817a..06a84dc794 100755 --- a/pynest/examples/one_neuron.py +++ b/pynest/examples/one_neuron.py @@ -50,7 +50,7 @@ # In this example we will configure these parameters in an additional # step, which is explained in the third section. -neuron = nest.Create("iaf_neuron") +neuron = nest.Create("iaf_psc_alpha") voltmeter = nest.Create("voltmeter") # Third, the neuron and the voltmeter are configured using # `SetStatus()`, which expects a list of node handles and a list of diff --git a/pynest/examples/one_neuron_with_noise.py b/pynest/examples/one_neuron_with_noise.py index 2c5f9da7c2..3ddc5a660a 100755 --- a/pynest/examples/one_neuron_with_noise.py +++ b/pynest/examples/one_neuron_with_noise.py @@ -24,7 +24,7 @@ nest.ResetKernel() -neuron = nest.Create("iaf_neuron") +neuron = nest.Create("iaf_psc_alpha") noise = nest.Create("poisson_generator", 2) nest.SetStatus(noise, [{"rate": 80000.0}, {"rate": 15000.0}]) diff --git a/pynest/examples/structural_plasticity.py b/pynest/examples/structural_plasticity.py index 8d3fe9e029..8cbea654e1 100644 --- a/pynest/examples/structural_plasticity.py +++ b/pynest/examples/structural_plasticity.py @@ -214,11 +214,11 @@ def create_nodes(self): size excitatory neurons and another one with 20% of the total network size of inhibitory neurons. ''' - self.nodes_e = nest.Create('iaf_neuron', + self.nodes_e = nest.Create('iaf_psc_alpha', self.number_excitatory_neurons, {'synaptic_elements': synaptic_elements}) - self.nodes_i = nest.Create('iaf_neuron', + self.nodes_i = nest.Create('iaf_psc_alpha', self.number_inhibitory_neurons, {'synaptic_elements': synaptic_elements_i}) nest.SetStatus(self.nodes_e, 'synaptic_elements', synaptic_elements) diff --git a/pynest/examples/testiaf.py b/pynest/examples/testiaf.py index ee371ae0b6..36e24f7148 100755 --- a/pynest/examples/testiaf.py +++ b/pynest/examples/testiaf.py @@ -50,7 +50,7 @@ def build_network(dt): nest.ResetKernel() nest.SetKernelStatus({"local_num_threads": 1, "resolution": dt}) - neuron = nest.Create('iaf_neuron') + neuron = nest.Create('iaf_psc_alpha') nest.SetStatus(neuron, "I_e", 376.0) vm = nest.Create('voltmeter') diff --git a/pynest/examples/twoneurons.py b/pynest/examples/twoneurons.py index 7922ccf4a1..8d4e0eda51 100644 --- a/pynest/examples/twoneurons.py +++ b/pynest/examples/twoneurons.py @@ -28,8 +28,8 @@ delay = 1.0 stim = 1000.0 -neuron1 = nest.Create("iaf_neuron") -neuron2 = nest.Create("iaf_neuron") +neuron1 = nest.Create("iaf_psc_alpha") +neuron2 = nest.Create("iaf_psc_alpha") voltmeter = nest.Create("voltmeter") nest.SetStatus(neuron1, {"I_e": stim}) diff --git a/pynest/nest/lib/hl_api_connections.py b/pynest/nest/lib/hl_api_connections.py index 78637bfa89..edda2cd5f3 100644 --- a/pynest/nest/lib/hl_api_connections.py +++ b/pynest/nest/lib/hl_api_connections.py @@ -27,6 +27,8 @@ from .hl_api_nodes import Create from .hl_api_info import GetStatus from .hl_api_simulation import GetKernelStatus, SetKernelStatus +from .hl_api_subnets import GetChildren +import hl_api_helper as hlh import numpy @@ -451,7 +453,15 @@ def _is_subnet_instance(gids): """ try: + # Turn off _deprecation_warning as users shouldn't change + # implementation of this function, it is done by the developers + deprecation_bool = hlh._deprecation_warning['GetChildren'] + hlh._deprecation_warning['GetChildren'] = False + GetChildren(gids) + + # Need to reset the deprecation warning to its old value + hlh._deprecation_warning['GetChildren'] = deprecation_bool return True except kernel.NESTError: return False diff --git a/pynest/nest/lib/hl_api_helper.py b/pynest/nest/lib/hl_api_helper.py index dcb3adb22b..dccd3aa070 100644 --- a/pynest/nest/lib/hl_api_helper.py +++ b/pynest/nest/lib/hl_api_helper.py @@ -413,7 +413,8 @@ def model_deprecation_warning(model): """ deprecated_models = {'subnet': 'GIDCollection', - 'aeif_cond_alpha_RK5': 'aeif_cond_alpha'} + 'aeif_cond_alpha_RK5': 'aeif_cond_alpha', + 'iaf_neuron': 'iaf_cond_alpha'} if model in deprecated_models: text = "The {0} model is deprecated and will be removed in a \ diff --git a/pynest/nest/lib/hl_api_nodes.py b/pynest/nest/lib/hl_api_nodes.py index 923f02c2eb..c43e0dc1a7 100644 --- a/pynest/nest/lib/hl_api_nodes.py +++ b/pynest/nest/lib/hl_api_nodes.py @@ -74,7 +74,7 @@ def Create(model, n=1, params=None): @check_stack -@deprecated('', 'GetLID is deprecated and will be removed in NEST3. Use \ +@deprecated('', 'GetLID is deprecated and will be removed in NEST 3.0. Use \ index into GIDCollection instead.') def GetLID(gid): """Return the local id of a node with the global ID gid. diff --git a/pynest/nest/lib/hl_api_subnets.py b/pynest/nest/lib/hl_api_subnets.py index eb44d11b73..86f25c42aa 100644 --- a/pynest/nest/lib/hl_api_subnets.py +++ b/pynest/nest/lib/hl_api_subnets.py @@ -66,7 +66,7 @@ def PrintNetwork(depth=1, subnet=None): @check_stack -@deprecated('', 'CurrentSubnet is deprecated and will be removed in NEST3.') +@deprecated('', 'CurrentSubnet is deprecated and will be removed in NEST 3.0.') def CurrentSubnet(): """Returns the global id of the current subnet. @@ -81,7 +81,7 @@ def CurrentSubnet(): @check_stack -@deprecated('', 'ChangeSubnet is deprecated and will be removed in NEST3.') +@deprecated('', 'ChangeSubnet is deprecated and will be removed in NEST 3.0.') def ChangeSubnet(subnet): """Make given subnet the current. @@ -103,7 +103,7 @@ def ChangeSubnet(subnet): @check_stack -@deprecated('', 'GetLeaves is deprecated and will be removed in NEST3. Use \ +@deprecated('', 'GetLeaves is deprecated and will be removed in NEST 3.0. Use \ GIDCollection instead.') def GetLeaves(subnets, properties=None, local_only=False): """Return the GIDs of the leaf nodes of the given subnets. @@ -144,7 +144,7 @@ def GetLeaves(subnets, properties=None, local_only=False): @check_stack -@deprecated('', 'GetNodes is deprecated and will be removed in NEST3. Use \ +@deprecated('', 'GetNodes is deprecated and will be removed in NEST 3.0. Use \ GIDCollection instead.') def GetNodes(subnets, properties=None, local_only=False): """Return the global ids of the all nodes of the given subnets. @@ -183,7 +183,7 @@ def GetNodes(subnets, properties=None, local_only=False): @check_stack -@deprecated('', 'GetChilden is deprecated and will be removed in NEST3. Use \ +@deprecated('', 'GetChilden is deprecated and will be removed in NEST 3.0. Use \ GIDCollection instead.') def GetChildren(subnets, properties=None, local_only=False): """Return the global ids of the immediate children of the given subnets. @@ -222,7 +222,7 @@ def GetChildren(subnets, properties=None, local_only=False): @check_stack -@deprecated('', 'GetNetwork is deprecated and will be removed in Nest3.\ +@deprecated('', 'GetNetwork is deprecated and will be removed in Nest 3.0.\ Script is responsible for retaining structure information if needed') def GetNetwork(gid, depth): """Return a nested list with the children of subnet id at level @@ -256,8 +256,8 @@ def GetNetwork(gid, depth): @check_stack -@deprecated('', 'BeginSubnet is deprecated and will be removed in NEST3. Use \ -GIDCollection instead.') +@deprecated('', 'BeginSubnet is deprecated and will be removed in NEST 3.0. \ +Use GIDCollection instead.') def BeginSubnet(label=None, params=None): """Create a new subnet and change into it. @@ -278,7 +278,7 @@ def BeginSubnet(label=None, params=None): @check_stack -@deprecated('', 'EndSubnet is deprecated and will be removed in NEST3. Use \ +@deprecated('', 'EndSubnet is deprecated and will be removed in NEST 3.0. Use \ GIDCollection instead.') def EndSubnet(): """Change to the parent subnet and return the gid of the current. @@ -301,7 +301,7 @@ def EndSubnet(): @check_stack -@deprecated('', 'LayoutNetwork is deprecated and will be removed in NEST3. \ +@deprecated('', 'LayoutNetwork is deprecated and will be removed in NEST 3.0. \ Use Create(, n=) instead.') def LayoutNetwork(model, dim, label=None, params=None): """Create a subnetwork of dimension dim with nodes of type model and diff --git a/topology/examples/conncomp.py b/topology/examples/conncomp.py index 64f6bc26d9..19bfd591ba 100644 --- a/topology/examples/conncomp.py +++ b/topology/examples/conncomp.py @@ -41,8 +41,8 @@ nest.set_verbosity('M_WARNING') # create two test layers -nest.CopyModel('iaf_neuron', 'pyr') -nest.CopyModel('iaf_neuron', 'in') +nest.CopyModel('iaf_psc_alpha', 'pyr') +nest.CopyModel('iaf_psc_alpha', 'in') a = topo.CreateLayer({'columns': 30, 'rows': 30, 'extent': [3.0, 3.0], 'elements': ['pyr', 'in']}) diff --git a/topology/examples/conncon_sources.py b/topology/examples/conncon_sources.py index 74555306a1..2eee0ffe52 100644 --- a/topology/examples/conncon_sources.py +++ b/topology/examples/conncon_sources.py @@ -42,9 +42,9 @@ # create two test layers a = topo.CreateLayer({'columns': 30, 'rows': 30, 'extent': [3.0, 3.0], - 'elements': 'iaf_neuron', 'edge_wrap': True}) + 'elements': 'iaf_psc_alpha', 'edge_wrap': True}) b = topo.CreateLayer({'columns': 30, 'rows': 30, 'extent': [3.0, 3.0], - 'elements': 'iaf_neuron', 'edge_wrap': True}) + 'elements': 'iaf_psc_alpha', 'edge_wrap': True}) topo.ConnectLayers(a, b, {'connection_type': 'convergent', 'mask': {'rectangular': {'lower_left': [-0.2, -0.5], diff --git a/topology/examples/conncon_targets.py b/topology/examples/conncon_targets.py index 96af52bdb7..35d4f4bb86 100644 --- a/topology/examples/conncon_targets.py +++ b/topology/examples/conncon_targets.py @@ -40,9 +40,9 @@ # create two test layers a = topo.CreateLayer({'columns': 30, 'rows': 30, 'extent': [3.0, 3.0], - 'elements': 'iaf_neuron', 'edge_wrap': True}) + 'elements': 'iaf_psc_alpha', 'edge_wrap': True}) b = topo.CreateLayer({'columns': 30, 'rows': 30, 'extent': [3.0, 3.0], - 'elements': 'iaf_neuron', 'edge_wrap': True}) + 'elements': 'iaf_psc_alpha', 'edge_wrap': True}) conndict = {'connection_type': 'convergent', 'mask': {'rectangular': {'lower_left': [-0.2, -0.5], diff --git a/topology/examples/connex.py b/topology/examples/connex.py index c59b5dce97..aa5a66d04b 100644 --- a/topology/examples/connex.py +++ b/topology/examples/connex.py @@ -41,9 +41,9 @@ # create two test layers a = topo.CreateLayer({'columns': 30, 'rows': 30, 'extent': [3.0, 3.0], - 'elements': 'iaf_neuron'}) + 'elements': 'iaf_psc_alpha'}) b = topo.CreateLayer({'columns': 30, 'rows': 30, 'extent': [3.0, 3.0], - 'elements': 'iaf_neuron'}) + 'elements': 'iaf_psc_alpha'}) conndict = {'connection_type': 'divergent', 'mask': {'circular': {'radius': 0.5}}, diff --git a/topology/examples/connex_ew.py b/topology/examples/connex_ew.py index d26ecaf67a..ee6e1f178d 100644 --- a/topology/examples/connex_ew.py +++ b/topology/examples/connex_ew.py @@ -40,9 +40,9 @@ # create two test layers a = topo.CreateLayer({'columns': 30, 'rows': 30, 'extent': [3.0, 3.0], - 'elements': 'iaf_neuron'}) + 'elements': 'iaf_psc_alpha'}) b = topo.CreateLayer({'columns': 30, 'rows': 30, 'extent': [3.0, 3.0], - 'elements': 'iaf_neuron', 'edge_wrap': True}) + 'elements': 'iaf_psc_alpha', 'edge_wrap': True}) conndict = {'connection_type': 'divergent', 'mask': {'circular': {'radius': 0.5}}, diff --git a/topology/examples/ctx_2n.py b/topology/examples/ctx_2n.py index 8caba2dd26..3214496ec2 100644 --- a/topology/examples/ctx_2n.py +++ b/topology/examples/ctx_2n.py @@ -38,8 +38,8 @@ nest.ResetKernel() -nest.CopyModel('iaf_neuron', 'pyr') -nest.CopyModel('iaf_neuron', 'in') +nest.CopyModel('iaf_psc_alpha', 'pyr') +nest.CopyModel('iaf_psc_alpha', 'in') ctx = topo.CreateLayer({'columns': 4, 'rows': 3, 'extent': [2.0, 1.5], 'elements': ['pyr', 'in']}) diff --git a/topology/examples/gaussex.py b/topology/examples/gaussex.py index 120ca80839..ebb71aeb88 100644 --- a/topology/examples/gaussex.py +++ b/topology/examples/gaussex.py @@ -39,9 +39,9 @@ # create two test layers a = topo.CreateLayer({'columns': 30, 'rows': 30, 'extent': [3.0, 3.0], - 'elements': 'iaf_neuron'}) + 'elements': 'iaf_psc_alpha'}) b = topo.CreateLayer({'columns': 30, 'rows': 30, 'extent': [3.0, 3.0], - 'elements': 'iaf_neuron'}) + 'elements': 'iaf_psc_alpha'}) conndict = {'connection_type': 'divergent', 'mask': {'circular': {'radius': 3.0}}, diff --git a/topology/examples/grid_iaf.py b/topology/examples/grid_iaf.py index 0a95e24828..6f029f18ad 100644 --- a/topology/examples/grid_iaf.py +++ b/topology/examples/grid_iaf.py @@ -38,7 +38,7 @@ l1 = topo.CreateLayer({'columns': 4, 'rows': 3, 'extent': [2.0, 1.5], - 'elements': 'iaf_neuron'}) + 'elements': 'iaf_psc_alpha'}) nest.PrintNetwork() nest.PrintNetwork(2) diff --git a/topology/examples/grid_iaf_irr.py b/topology/examples/grid_iaf_irr.py index 8fa6272583..7962e17692 100644 --- a/topology/examples/grid_iaf_irr.py +++ b/topology/examples/grid_iaf_irr.py @@ -43,7 +43,7 @@ l1 = topo.CreateLayer({'extent': [2., 1.5], 'positions': pos, - 'elements': 'iaf_neuron'}) + 'elements': 'iaf_psc_alpha'}) nest.PrintNetwork() nest.PrintNetwork(2) diff --git a/topology/examples/grid_iaf_oc.py b/topology/examples/grid_iaf_oc.py index daf6f67239..7fda8bfe92 100644 --- a/topology/examples/grid_iaf_oc.py +++ b/topology/examples/grid_iaf_oc.py @@ -41,7 +41,7 @@ l1 = topo.CreateLayer({'columns': 4, 'rows': 3, 'extent': [2.0, 1.5], 'center': ctr, - 'elements': 'iaf_neuron'}) + 'elements': 'iaf_psc_alpha'}) topo.PlotLayer(l1, nodesize=50, fig=pylab.gcf()) diff --git a/topology/examples/test_3d.py b/topology/examples/test_3d.py index b56a486eeb..3e3299701a 100644 --- a/topology/examples/test_3d.py +++ b/topology/examples/test_3d.py @@ -49,7 +49,7 @@ {'extent': [1.5, 1.5, 1.5], # must specify 3d extent AND center 'center': [0., 0., 0.], 'positions': pos, - 'elements': 'iaf_neuron'}) + 'elements': 'iaf_psc_alpha'}) # visualize # xext, yext = nest.GetStatus(l1, 'topology')[0]['extent'] diff --git a/topology/examples/test_3d_exp.py b/topology/examples/test_3d_exp.py index 64e8c0262b..297d7bfd84 100644 --- a/topology/examples/test_3d_exp.py +++ b/topology/examples/test_3d_exp.py @@ -49,7 +49,7 @@ {'extent': [1.5, 1.5, 1.5], # must specify 3d extent AND center 'center': [0., 0., 0.], 'positions': pos, - 'elements': 'iaf_neuron'}) + 'elements': 'iaf_psc_alpha'}) # visualize # xext, yext = nest.GetStatus(l1, 'topology')[0]['extent'] diff --git a/topology/examples/test_3d_gauss.py b/topology/examples/test_3d_gauss.py index 31b9e12ed3..c4bbf4a2f7 100644 --- a/topology/examples/test_3d_gauss.py +++ b/topology/examples/test_3d_gauss.py @@ -49,7 +49,7 @@ {'extent': [1.5, 1.5, 1.5], # must specify 3d extent AND center 'center': [0., 0., 0.], 'positions': pos, - 'elements': 'iaf_neuron'}) + 'elements': 'iaf_psc_alpha'}) # visualize # xext, yext = nest.GetStatus(l1, 'topology')[0]['extent'] diff --git a/topology/pynest/hl_api.py b/topology/pynest/hl_api.py index 6c70f2ebff..8fa3d6a95d 100644 --- a/topology/pynest/hl_api.py +++ b/topology/pynest/hl_api.py @@ -627,6 +627,14 @@ def CreateLayer(specs): specs = (specs, ) elif not all(isinstance(spec, dict) for spec in specs): raise TypeError("specs must be a dictionary or a list of dictionaries") + + for dicts in specs: + elements = dicts['elements'] + if isinstance(elements, list): + for elem in elements: + hlh.model_deprecation_warning(elem) + else: + hlh.model_deprecation_warning(elements) return topology_func('{ CreateLayer } Map', specs) From 7aabc1f70de62ee3b3fc7eae632a47cf4377e524 Mon Sep 17 00:00:00 2001 From: Stine Vennemo Date: Tue, 13 Dec 2016 16:18:27 +0100 Subject: [PATCH 09/16] Fixed formatting. --- models/modelsmodule.cpp | 5 +++-- nestkernel/nestmodule.cpp | 6 ++++-- topology/pynest/hl_api.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/models/modelsmodule.cpp b/models/modelsmodule.cpp index 718845cbc5..93577f58cd 100644 --- a/models/modelsmodule.cpp +++ b/models/modelsmodule.cpp @@ -358,8 +358,9 @@ ModelsModule::init( SLIInterpreter* ) #endif // This version of the AdEx model does not depend on GSL. kernel().model_manager.register_node_model< aeif_cond_alpha_RK5 >( - "aeif_cond_alpha_RK5", /*private_model*/ false, - /*deprecation_model*/ "NEST 3.0" ); + "aeif_cond_alpha_RK5", + /*private_model*/ false, + /*deprecation_model*/ "NEST 3.0" ); kernel().model_manager.register_node_model< aeif_cond_alpha_multisynapse >( "aeif_cond_alpha_multisynapse" ); diff --git a/nestkernel/nestmodule.cpp b/nestkernel/nestmodule.cpp index 61579518f0..22e7d97837 100644 --- a/nestkernel/nestmodule.cpp +++ b/nestkernel/nestmodule.cpp @@ -1617,7 +1617,8 @@ NestModule::init( SLIInterpreter* i ) i->createcommand( "CurrentSubnet", ¤tsubnetfunction, "NEST 3.0" ); i->createcommand( "GetNodes_i_D_b_b", &getnodes_i_D_b_bfunction, "NEST 3.0" ); i->createcommand( "GetLeaves_i_D_b", &getleaves_i_D_bfunction, "NEST 3.0" ); - i->createcommand( "GetChildren_i_D_b", &getchildren_i_D_bfunction, "NEST 3.0" ); + i->createcommand( + "GetChildren_i_D_b", &getchildren_i_D_bfunction, "NEST 3.0" ); i->createcommand( "RestoreNodes_a", &restorenodes_afunction ); @@ -1642,7 +1643,8 @@ NestModule::init( SLIInterpreter* i ) i->createcommand( "Connect_g_g_D_D", &connect_g_g_D_Dfunction ); - i->createcommand( "DataConnect_i_D_s", &dataconnect_i_D_sfunction, "NEST 3.0" ); + i->createcommand( + "DataConnect_i_D_s", &dataconnect_i_D_sfunction, "NEST 3.0" ); i->createcommand( "DataConnect_a", &dataconnect_afunction, "NEST 3.0" ); i->createcommand( "ResetNetwork", &resetnetworkfunction ); diff --git a/topology/pynest/hl_api.py b/topology/pynest/hl_api.py index 8fa3d6a95d..46bacdefa9 100644 --- a/topology/pynest/hl_api.py +++ b/topology/pynest/hl_api.py @@ -627,7 +627,7 @@ def CreateLayer(specs): specs = (specs, ) elif not all(isinstance(spec, dict) for spec in specs): raise TypeError("specs must be a dictionary or a list of dictionaries") - + for dicts in specs: elements = dicts['elements'] if isinstance(elements, list): From 0e98846223c840e1196b4108e46ca5b4591aaec7 Mon Sep 17 00:00:00 2001 From: Stine Vennemo Date: Thu, 15 Dec 2016 15:49:16 +0100 Subject: [PATCH 10/16] Added M_DEPRECATED to list of possible messages in order to suppress some SLI-deprecations on Python level. Made sure SLI remember if deprecation warnings were issued for GetNetwork and LayoutNetwork. Made helper function to supress and reset deprecation warnings on Python level. --- lib/sli/misc_helpers.sli | 51 +++++++++++-------- lib/sli/nest-init.sli | 65 +++++++++++++------------ libnestutil/logging.h | 1 + libnestutil/logging_event.cpp | 3 ++ nestkernel/genericmodel_impl.h | 2 +- pynest/examples/csa_topology_example.py | 12 +++-- pynest/nest/lib/hl_api_helper.py | 60 +++++++++++++++++++++++ pynest/nest/lib/hl_api_info.py | 3 +- pynest/nest/lib/hl_api_subnets.py | 13 +++-- sli/functiondatum.h | 2 +- sli/interpret.cc | 4 ++ sli/interpret.h | 5 ++ sli/slistartup.cc | 5 ++ topology/examples/ctx_2n.py | 6 ++- topology/examples/hill_tononi_Vp.py | 8 ++- topology/examples/test_3d.py | 6 ++- topology/examples/test_3d_exp.py | 6 ++- topology/examples/test_3d_gauss.py | 6 ++- topology/pynest/hl_api.py | 31 ++++++------ 19 files changed, 203 insertions(+), 86 deletions(-) diff --git a/lib/sli/misc_helpers.sli b/lib/sli/misc_helpers.sli index 935de1c74b..6299320553 100644 --- a/lib/sli/misc_helpers.sli +++ b/lib/sli/misc_helpers.sli @@ -38,7 +38,7 @@ Synopsis: Priority (From) (Message) message -> where "Priority" may be any positive integer, or one of the following: -M_DEBUG, M_STATUS, M_INFO, M_WARNING, M_ERROR, M_FATAL +M_DEBUG, M_STATUS, M_INFO, M_DEPRECATED, M_WARNING, M_ERROR, M_FATAL Description: Display a message, if priority is higher than current verbosity-level. @@ -87,15 +87,19 @@ Examples: Short form: issues something like % Jul 21 16:24:12 SLI[10] Your last action had no effect - 4. (Result may be invalid) M_WARNING message + 4. (Function is deprecated) M_DEPRECATED message + issues something like + % Jul 21 16:24:12 SLI[18] Function is deprecated + + 5. (Result may be invalid) M_WARNING message issues something like % Jul 21 16:24:24 SLI[20] Result may be invalid - 5. (This should never happen!) M_ERROR message + 6. (This should never happen!) M_ERROR message issues something like % Jul 21 16:24:36 SLI[30] This should never happen! - 6. (It's all broken, let's go home.) M_FATAL message + 7. (It's all broken, let's go home.) M_FATAL message issues something like % Jul 21 16:24:36 SLI[40] It's all broken, let's go home. @@ -116,15 +120,16 @@ FirstVersion: Apr 9 1999 Remarks: M_* values are defined in system dictionary. You may introduce new priority levels in the user dictionary if convenient. - Standard values are: M_ALL = 0 - M_DEBUG = 5 - M_STATUS = 7 - M_INFO = 10 - M_WARNING = 20 - M_ERROR = 30 - M_FATAL = 40 - M_QUIET = 100 - Standard output: M_OUT = cout + Standard values are: M_ALL = 0 + M_DEBUG = 5 + M_STATUS = 7 + M_INFO = 10 + M_DEPRECATED = 18 + M_WARNING = 20 + M_ERROR = 30 + M_FATAL = 40 + M_QUIET = 100 + Standard output: M_OUT = cout SeeAlso: setverbosity */ @@ -134,14 +139,15 @@ systemdict begin %this is unnessessary, if misc_helpers.sli is called from sli-i % but that's not sure, and it won't harm anyway... %Define error levels: - /M_ALL 0 def - /M_DEBUG 5 def - /M_STATUS 7 def - /M_INFO 10 def - /M_WARNING 20 def - /M_ERROR 30 def - /M_FATAL 40 def - /M_QUIET 100 def + /M_ALL 0 def + /M_DEBUG 5 def + /M_STATUS 7 def + /M_INFO 10 def + /M_DEPRECATED 18 def + /M_WARNING 20 def + /M_ERROR 30 def + /M_FATAL 40 def + /M_QUIET 100 def end %systemdict @@ -170,6 +176,7 @@ VerbosityLevel setverbosity -> - M_DEBUG setverbosity -> - M_STATUS setverbosity -> - M_INFO setverbosity -> - +M_DEPRECATED setverbosity -> - M_WARNING setverbosity -> - M_ERROR setverbosity -> - M_FATAL setverbosity -> - @@ -190,6 +197,7 @@ Parameters: M_DEBUG=5, display debugging messages and above M_STATUS=7, display status messages and above M_INFO=10, display information messages and above + M_DEPRECATED=18, display deprecation warnings and above M_WARNING=20, display warning messages and above M_ERROR=30, display error messages and above M_FATAL=40, display failure messages and above @@ -223,6 +231,7 @@ Remarks: M_DEBUG = 5 M_STATUS = 7 M_INFO = 10 + M_DEPRECATED = 18 M_WARNING = 20 M_ERROR = 30 M_FATAL = 40 diff --git a/lib/sli/nest-init.sli b/lib/sli/nest-init.sli index 181bb17ca8..d573e1b9ea 100644 --- a/lib/sli/nest-init.sli +++ b/lib/sli/nest-init.sli @@ -732,15 +732,17 @@ def SeeAlso: Create, LayoutArray */ -true /first_deprecation_warning Set +/LayoutNetwork +<< /deprecation_warning true >> +Options /LayoutNetwork_l_a_dict { << >> begin - first_deprecation_warning true eq + /LayoutNetwork /deprecation_warning GetOption true eq { - (Sli function LayoutNetwork is deprecated in NEST 3.0.) M_WARNING message - false /first_deprecation_warning Set + (Sli function LayoutNetwork is deprecated in NEST 3.0.) M_DEPRECATED message + /LayoutNetwork << /deprecation_warning false >> SetOptions } if /val Set size /n_dim Set @@ -782,10 +784,10 @@ true /first_deprecation_warning Set /LayoutNetwork_l_a { << >> begin - first_deprecation_warning true eq + /LayoutNetwork /deprecation_warning GetOption true eq { - (Sli function LayoutNetwork is deprecated in NEST 3.0.) M_WARNING message - false /first_deprecation_warning Set + (Sli function LayoutNetwork is deprecated in NEST 3.0.) M_DEPRECATED message + /LayoutNetwork << /deprecation_warning false >> SetOptions } if size /n_dim Set dup 0 get /n Set @@ -1234,29 +1236,6 @@ def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -true /first_deprecation_warning Set - -/GetNetwork_i_i { - << >> begin - first_deprecation_warning true eq - { - (Sli function GetNetwork is deprecated in NEST 3.0.) M_WARNING message - false /first_deprecation_warning Set - } if - /depth Set - dup - GetStatus /model get % id model - /subnet eq depth 1 geq and { % id - dup % id id - [ - exch % id [ id - GetGlobalChildren { depth 1 sub GetNetwork_i_i } forall - ] - exch prepend - } if - end -} def - /* BeginDocumentation Name: GetNetwork - Return a nested list with the IDs of nodes in a multi-dimensional subnet. Synpsis: ID n GetNetwork -> [ ] @@ -1280,6 +1259,32 @@ and can thus take a lot of time and consume huge amounts of memory. SeeAlso: GetGlobalNodes, GetLocalNodes, GetGlobalLeaves, GetLocalLeaves, GetGlobalChildren, GetLocalChildren */ + +/GetNetwork +<< /deprecation_warning true >> +Options + +/GetNetwork_i_i { + << >> begin + /GetNetwork /deprecation_warning GetOption true eq + { + (Sli function GetNetwork is deprecated in NEST 3.0.) M_DEPRECATED message + /GetNetwork << /deprecation_warning false >> SetOptions + } if + /depth Set + dup + GetStatus /model get % id model + /subnet eq depth 1 geq and { % id + dup % id id + [ + exch % id [ id + GetGlobalChildren { depth 1 sub GetNetwork_i_i } forall + ] + exch prepend + } if + end +} def + /GetNetwork trie [/integertype /integertype] /GetNetwork_i_i load addtotrie def diff --git a/libnestutil/logging.h b/libnestutil/logging.h index 0cff8d3597..c71324a49a 100644 --- a/libnestutil/logging.h +++ b/libnestutil/logging.h @@ -56,6 +56,7 @@ enum severity_t M_DEBUG = 5, M_STATUS = 7, M_INFO = 10, + M_DEPRECATED = 18, M_WARNING = 20, M_ERROR = 30, M_FATAL = 40, diff --git a/libnestutil/logging_event.cpp b/libnestutil/logging_event.cpp index fe2177cb61..8acf2647c2 100644 --- a/libnestutil/logging_event.cpp +++ b/libnestutil/logging_event.cpp @@ -63,6 +63,9 @@ std::ostream& operator<<( std::ostream& out, const LoggingEvent& e ) case M_INFO: out << "[INFO] "; break; + case M_DEPRECATED: + out << "[INFO] "; + break; case M_WARNING: out << "[WARNING] "; break; diff --git a/nestkernel/genericmodel_impl.h b/nestkernel/genericmodel_impl.h index d23ad94726..3b4122b459 100644 --- a/nestkernel/genericmodel_impl.h +++ b/nestkernel/genericmodel_impl.h @@ -41,7 +41,7 @@ GenericModel< ElementT >::deprecation_warning( const std::string& caller ) if ( not deprecation_info_.empty() ) { - LOG( M_WARNING, + LOG( M_DEPRECATED, caller, "Model " + get_name() + " is deprecated in " + deprecation_info_ + "." ); } diff --git a/pynest/examples/csa_topology_example.py b/pynest/examples/csa_topology_example.py index 71117d2499..0c1acec763 100644 --- a/pynest/examples/csa_topology_example.py +++ b/pynest/examples/csa_topology_example.py @@ -35,6 +35,9 @@ For a related example, see csa_example.py +This example uses the function GetLeaves, which is deprecated. A deprecation +warning is therefore released. For details about deprecated functions, see +documentation. """ """ @@ -113,11 +116,12 @@ def geometry_function(idx): associated with the connection set. """ -# Find the gids to use in CGConnect, this is a work-around until NEST 3.0. -pop1_gids = nest.GetLeaves(pop1) -pop2_gids = nest.GetLeaves(pop2) +# This is a work-around until NEST 3.0 is released. It will issue a deprecation +# warning. +pop1_gids = nest.GetLeaves(pop1)[0] +pop2_gids = nest.GetLeaves(pop2)[0] -nest.CGConnect(pop1_gids[0], pop2_gids[0], cs, {"weight": 0, "delay": 1}) +nest.CGConnect(pop1_gids, pop2_gids, cs, {"weight": 0, "delay": 1}) """ Finally, we use the `PlotTargets` function to show all targets in diff --git a/pynest/nest/lib/hl_api_helper.py b/pynest/nest/lib/hl_api_helper.py index dccd3aa070..1bb15aa2da 100644 --- a/pynest/nest/lib/hl_api_helper.py +++ b/pynest/nest/lib/hl_api_helper.py @@ -422,3 +422,63 @@ def model_deprecation_warning(model): ".format(model, deprecated_models[model]) text = get_wrapped_text(text) warnings.warn('\n' + text) + + +def turn_of_deprecation_warning(deprecated_func_name): + """Turns of deprecation warnings on SLI and Python level for given function. + + Think thouroughly before use. The function should only be used as a way to + make sure examples do not display deprecation warnings, that is, used in + functions called from examples, and not as a way to make tedious + deprecation warnings dissapear. + + NB! Remember to always use turn_on_deprecation_warning(deprecated_func_name, + deprecation_bool, verbosity_level) after deprecated function is called, so + as to reset the deprecation warnings to their old value. + + Parameters + ---------- + deprecated_func_name: str + Name of deprecated function + + Returns + ------- + bool and int: + Present deprecation warning status and verbosity level + """ + + # Need to know the present deprecation warning status so we can reset after + # function is called + deprecation_bool = _deprecation_warning[deprecated_func_name] + _deprecation_warning[deprecated_func_name] = False + verbosity_level = nest.get_verbosity() + # Verbosity level for deprecation warnings is 18, so if verbosity level is + # greater we don't need to turn of deprecation warnings from SLI + if verbosity_level <= 18: + nest.set_verbosity(20) + + return deprecation_bool, verbosity_level + + +def turn_on_deprecation_warning(deprecated_func_name, deprecation_bool, + verbosity_level): + """Return deprecation warning status back to original value. + + Whenever turn_of_deprecation_warning(deprecated_func_name) is used, this + function must be called in order to reset to original status. + + Parameters + ---------- + deprecated_func_name: str + Name of deprecated function + deprecation_bool: bool + Original status of _deprecation_warning[deprecated_func_name] + verbosity_level: int + Original verbosity level + """ + + # Need to reset the deprecation warnings to their old value + if verbosity_level <= 18: + nest.set_verbosity(verbosity_level) + + _deprecation_warning[deprecated_func_name] = deprecation_bool diff --git a/pynest/nest/lib/hl_api_info.py b/pynest/nest/lib/hl_api_info.py index 4a14b0d11d..2f5e56225c 100644 --- a/pynest/nest/lib/hl_api_info.py +++ b/pynest/nest/lib/hl_api_info.py @@ -124,7 +124,8 @@ def set_verbosity(level): Parameters ---------- level : str - Can be one of 'M_FATAL', 'M_ERROR', 'M_WARNING', or 'M_INFO'. + Can be one of 'M_FATAL', 'M_ERROR', 'M_WARNING', 'M_DEPRECATED', + 'M_INFO' or 'M_ALL'. """ sr("%s setverbosity" % level) diff --git a/pynest/nest/lib/hl_api_subnets.py b/pynest/nest/lib/hl_api_subnets.py index 86f25c42aa..3081e1f3bb 100644 --- a/pynest/nest/lib/hl_api_subnets.py +++ b/pynest/nest/lib/hl_api_subnets.py @@ -49,15 +49,14 @@ def PrintNetwork(depth=1, subnet=None): """ if subnet is None: - # Turn off _deprecation_warning as users shouldn't change - # implementation of PrintNetwork, it is done by the developers - deprecation_bool = hlh._deprecation_warning['CurrentSubnet'] - hlh._deprecation_warning['CurrentSubnet'] = False - + # Turn off deprecation warning on Python and SLI level as users + # shouldn't change implementation of PrintNetwork, it is done by the + # developers. + deprecation_bool, verbosity_level = turn_of_deprecation_warning('CurrentSubnet') subnet = CurrentSubnet() - # Need to reset the deprecation warning to its old value - hlh._deprecation_warning['CurrentSubnet'] = deprecation_bool + turn_on_deprecation_warning('CurrentSubnet', deprecation_bool, verbosity_level) + elif len(subnet) > 1: raise NESTError("PrintNetwork() expects exactly one GID.") diff --git a/sli/functiondatum.h b/sli/functiondatum.h index 0a7c43e917..b67f5deb2b 100644 --- a/sli/functiondatum.h +++ b/sli/functiondatum.h @@ -107,7 +107,7 @@ class FunctionDatum : public TypedDatum< &SLIInterpreter::Functiontype > { if ( not( deprecation_warning_issued_ or deprecation_info_.empty() ) ) { - i->message( SLIInterpreter::M_WARNING, + i->message( SLIInterpreter::M_DEPRECATED, "SLIInterpreter", ( "SLI function " + name.toString() + " is deprecated in " + deprecation_info_ + "." ).c_str() ); diff --git a/sli/interpret.cc b/sli/interpret.cc index 64acef6d01..4a17be29d3 100644 --- a/sli/interpret.cc +++ b/sli/interpret.cc @@ -75,6 +75,7 @@ const int SLIInterpreter::M_ALL = 0; const int SLIInterpreter::M_DEBUG = 5; const int SLIInterpreter::M_STATUS = 7; const int SLIInterpreter::M_INFO = 10; +const int SLIInterpreter::M_DEPRECATED = 18; const int SLIInterpreter::M_WARNING = 20; const int SLIInterpreter::M_ERROR = 30; const int SLIInterpreter::M_FATAL = 40; @@ -84,6 +85,7 @@ const char* const SLIInterpreter::M_ALL_NAME = ""; const char* const SLIInterpreter::M_DEBUG_NAME = "Debug"; const char* const SLIInterpreter::M_STATUS_NAME = "Status"; const char* const SLIInterpreter::M_INFO_NAME = "Info"; +const char* const SLIInterpreter::M_DEPRECATED_NAME = "Deprecated"; const char* const SLIInterpreter::M_WARNING_NAME = "Warning"; const char* const SLIInterpreter::M_ERROR_NAME = "Error"; const char* const SLIInterpreter::M_FATAL_NAME = "Fatal"; @@ -826,6 +828,8 @@ SLIInterpreter::message( int level, message( std::cout, M_ERROR_NAME, from, text, errorname ); else if ( level >= M_WARNING ) message( std::cout, M_WARNING_NAME, from, text, errorname ); + else if ( level >= M_DEPRECATED ) + message( std::cout, M_DEPRECATED_NAME, from, text, errorname ); else if ( level >= M_INFO ) message( std::cout, M_INFO_NAME, from, text, errorname ); else if ( level >= M_STATUS ) diff --git a/sli/interpret.h b/sli/interpret.h index f6e5b40188..284cb315fa 100644 --- a/sli/interpret.h +++ b/sli/interpret.h @@ -174,6 +174,8 @@ class SLIInterpreter static const int M_STATUS; //!< Predefined error level for status messages //! Predefined error level for informational messages static const int M_INFO; + static const int M_DEPRECATED; //!< Predefined error level for deprecation + //!< warnings static const int M_WARNING; //!< Predefined error level for warning messages static const int M_ERROR; //!< Predefined error level for error messages static const int M_FATAL; //!< Predefined error level for failure messages @@ -186,6 +188,7 @@ class SLIInterpreter static char const* const M_DEBUG_NAME; static char const* const M_STATUS_NAME; static char const* const M_INFO_NAME; + static char const* const M_DEPRECATED_NAME; static char const* const M_WARNING_NAME; static char const* const M_ERROR_NAME; static char const* const M_FATAL_NAME; @@ -785,6 +788,7 @@ class SLIInterpreter * SLIInterpreter::M_DEBUG=5, display debugging messages and above \n * SLIInterpreter::M_DEBUG=7, display status messages and above \n * SLIInterpreter::M_INFO=10, display information messages and above \n + * SLIInterpreter::M_DEPRECATED=18, display deprecation warnings and above \n * SLIInterpreter::M_WARNING=20, display warning messages and above \n * SLIInterpreter::M_ERROR=30, display error messages and above \n * SLIInterpreter::M_FATAL=40, display failure messages and above \n @@ -807,6 +811,7 @@ class SLIInterpreter * SLIInterpreter::M_DEBUG=5, a debugging message \n * SLIInterpreter::M_DEBUG=7, a status message \n * SLIInterpreter::M_INFO=10, an informational message \n + * SLIInterpreter::M_DEPRECATED=18, a deprecation warning \n * SLIInterpreter::M_WARNING=20, a warning message \n * SLIInterpreter::M_ERROR=30, an error message \n * SLIInterpreter::M_FATAL=40, a failure message. \n diff --git a/sli/slistartup.cc b/sli/slistartup.cc index 189b0dc895..b5656642cb 100644 --- a/sli/slistartup.cc +++ b/sli/slistartup.cc @@ -294,6 +294,11 @@ SLIStartup::SLIStartup( int argc, char** argv ) verbosity_ = SLIInterpreter::M_INFO; continue; } + if ( *sd == "--verbosity=DEPRECATED" ) + { + verbosity_ = SLIInterpreter::M_DEPRECATED; + continue; + } if ( *sd == "--verbosity=WARNING" ) { verbosity_ = SLIInterpreter::M_WARNING; diff --git a/topology/examples/ctx_2n.py b/topology/examples/ctx_2n.py index 3214496ec2..b84bde3574 100644 --- a/topology/examples/ctx_2n.py +++ b/topology/examples/ctx_2n.py @@ -27,6 +27,10 @@ BCCN Tutorial @ CNS*09 Hans Ekkehard Plesser, UMB + +This example uses the function GetLeaves, which is deprecated. A deprecation +warning is therefore released. For details about deprecated functions, see +documentation. ''' import nest @@ -50,7 +54,7 @@ nest.PrintNetwork(2, ctx) -# ctx_leaves is a work-around until NEST3 is released +# ctx_leaves is a work-around until NEST 3.0 is released ctx_leaves = nest.GetLeaves(ctx)[0] # extract position information diff --git a/topology/examples/hill_tononi_Vp.py b/topology/examples/hill_tononi_Vp.py index 5ad4cd05a8..72753c5bce 100644 --- a/topology/examples/hill_tononi_Vp.py +++ b/topology/examples/hill_tononi_Vp.py @@ -144,6 +144,10 @@ # ! **Note:** By default, the script does not show any graphics. # ! Set ``SHOW_FIGURES`` to ``True`` to activate graphics. +# ! This example uses the function GetLeaves, which is deprecated. A deprecation +# ! warning is therefore released. For details about deprecated functions, see +# ! documentation. + import pylab SHOW_FIGURES = False @@ -377,7 +381,7 @@ def phaseInit(pos, lam, alpha): layerProps.update({'elements': 'RetinaNode'}) retina = topo.CreateLayer(layerProps) -# retina_leaves is a work-around until NEST3 is released +# retina_leaves is a work-around until NEST 3.0 is released retina_leaves = nest.GetLeaves(retina)[0] # ! Now set phases of retinal oscillators; we use a list comprehension instead @@ -825,7 +829,7 @@ def phaseInit(pos, lam, alpha): ('Vp_v L4pyr', 3, Vp_v, 'L4pyr'), ('Vp_h L4pyr', 4, Vp_h, 'L4pyr')]: recorders[name] = (nest.Create('RecordingNode'), loc) - # population_leaves is a work-around until NEST3 is released + # population_leaves is a work-around until NEST 3.0 is released population_leaves = nest.GetLeaves(population)[0] tgts = [nd for nd in population_leaves if nest.GetStatus([nd], 'model')[0] == model] diff --git a/topology/examples/test_3d.py b/topology/examples/test_3d.py index 3e3299701a..a8079915d6 100644 --- a/topology/examples/test_3d.py +++ b/topology/examples/test_3d.py @@ -27,6 +27,10 @@ 3d layers are currently not supported, use at your own risk! Hans Ekkehard Plesser, UMB + +This example uses the function GetChildren, which is deprecated. A deprecation +warning is therefore released. For details about deprecated functions, see +documentation. ''' import nest @@ -55,7 +59,7 @@ # xext, yext = nest.GetStatus(l1, 'topology')[0]['extent'] # xctr, yctr = nest.GetStatus(l1, 'topology')[0]['center'] -# l1_children is a work-around until NEST3 is released +# l1_children is a work-around until NEST 3.0 is released l1_children = nest.GetChildren(l1)[0] # extract position information, transpose to list of x, y and z positions diff --git a/topology/examples/test_3d_exp.py b/topology/examples/test_3d_exp.py index 297d7bfd84..ca83ec191f 100644 --- a/topology/examples/test_3d_exp.py +++ b/topology/examples/test_3d_exp.py @@ -27,6 +27,10 @@ 3d layers are currently not supported, use at your own risk! Hans Ekkehard Plesser, UMB + +This example uses the function GetChildren, which is deprecated. A deprecation +warning is therefore released. For details about deprecated functions, see +documentation. ''' import nest @@ -55,7 +59,7 @@ # xext, yext = nest.GetStatus(l1, 'topology')[0]['extent'] # xctr, yctr = nest.GetStatus(l1, 'topology')[0]['center'] -# l1_children is a work-around until NEST3 is released +# l1_children is a work-around until NEST 3.0 is released l1_children = nest.GetChildren(l1)[0] # extract position information, transpose to list of x, y and z positions diff --git a/topology/examples/test_3d_gauss.py b/topology/examples/test_3d_gauss.py index c4bbf4a2f7..ada2f20880 100644 --- a/topology/examples/test_3d_gauss.py +++ b/topology/examples/test_3d_gauss.py @@ -27,6 +27,10 @@ 3d layers are currently not supported, use at your own risk! Hans Ekkehard Plesser, UMB + +This example uses the function GetChildren, which is deprecated. A deprecation +warning is therefore released. For details about deprecated functions, see +documentation. ''' import nest @@ -55,7 +59,7 @@ # xext, yext = nest.GetStatus(l1, 'topology')[0]['extent'] # xctr, yctr = nest.GetStatus(l1, 'topology')[0]['center'] -# l1_children is a work-around until NEST3 is released +# l1_children is a work-around until NEST 3.0 is released l1_children = nest.GetChildren(l1)[0] # extract position information, transpose to list of x, y and z positions diff --git a/topology/pynest/hl_api.py b/topology/pynest/hl_api.py index 46bacdefa9..b3f5dd0993 100644 --- a/topology/pynest/hl_api.py +++ b/topology/pynest/hl_api.py @@ -1619,17 +1619,18 @@ def GetTargetNodes(sources, tgt_layer, tgt_model=None, syn_model=None): if len(tgt_layer) != 1: raise nest.NESTError("tgt_layer must be a one-element list") - # Turn off _deprecation _warning as users shouldn't change implementation - # of GetTargetNodes, it is done by the developers - deprecation_bool = hlh._deprecation_warning['GetLeaves'] - hlh._deprecation_warning['GetLeaves'] = False + # Turn off deprecation warning on Python and SLI level as users + # shouldn't change implementation of GetTargetNodes, it is done by the + # developers. + deprecation_bool, verbosity_level = nest.turn_of_deprecation_warning('GetLeaves') + # obtain local nodes in target layer, to pass to GetConnections tgt_nodes = nest.GetLeaves(tgt_layer, properties={ 'model': tgt_model} if tgt_model else None, local_only=True)[0] # Need to reset the deprecation warning to its old value - hlh._deprecation_warning['GetLeaves'] = deprecation_bool + nest.turn_on_deprecation_warning('GetLeaves', deprecation_bool, verbosity_level) conns = nest.GetConnections(sources, tgt_nodes, synapse_model=syn_model) @@ -1801,14 +1802,14 @@ def PlotLayer(layer, fig=None, nodecolor='b', nodesize=20): xext, yext = ext xctr, yctr = nest.GetStatus(layer, 'topology')[0]['center'] - # Turn off _deprecation_warning as users shouldn't change - # implementation of PlotLayer, it is done by the developers - deprecation_bool = hlh._deprecation_warning['GetChildren'] - hlh._deprecation_warning['GetChildren'] = False + # Turn off deprecation warning on Python and SLI level as users + # shouldn't change implementation of PrintNetwork, it is done by the + # developers. + deprecation_bool, verbosity_level = nest.turn_of_deprecation_warning('GetChildren') # extract position information, transpose to list of x and y positions xpos, ypos = zip(*GetPosition(nest.GetChildren(layer)[0])) # Need to reset the deprecation warning to its old value - hlh._deprecation_warning['GetChildren'] = deprecation_bool + nest.turn_on_deprecation_warning('GetCildren', deprecation_bool, verbosity_level) if fig is None: fig = plt.figure() @@ -1824,14 +1825,14 @@ def PlotLayer(layer, fig=None, nodecolor='b', nodesize=20): # 3D layer from mpl_toolkits.mplot3d import Axes3D - # Turn off _deprecation_warning as users shouldn't change - # implementation of PlotLayer, it is done by the developers - deprecation_bool = hlh._deprecation_warning['GetChildren'] - hlh._deprecation_warning['GetChildren'] = False + # Turn off deprecation warning on Python and SLI level as users + # shouldn't change implementation of PrintNetwork, it is done by the + # developers. + deprecation_bool, verbosity_level = nest.turn_of_deprecation_warning('GetChildren') # extract position information, transpose to list of x,y,z positions pos = zip(*GetPosition(nest.GetChildren(layer)[0])) # Need to reset the deprecation warning to its old value - hlh._deprecation_warning['GetChildren'] = deprecation_bool + nest.turn_on_deprecation_warning('GetChildren', deprecation_bool, verbosity_level) if fig is None: fig = plt.figure() From dcc2685be72462265a9254e0b72f9ab63a80c2a3 Mon Sep 17 00:00:00 2001 From: Stine Vennemo Date: Thu, 15 Dec 2016 16:23:27 +0100 Subject: [PATCH 11/16] Fixed formatting. --- libnestutil/logging_event.cpp | 4 ++-- pynest/examples/csa_topology_example.py | 2 +- pynest/nest/lib/hl_api_helper.py | 13 +++++++------ pynest/nest/lib/hl_api_subnets.py | 8 +++++--- sli/interpret.cc | 2 +- sli/interpret.h | 2 +- topology/examples/ctx_2n.py | 2 +- topology/examples/hill_tononi_Vp.py | 6 +++--- topology/examples/test_3d.py | 2 +- topology/examples/test_3d_exp.py | 2 +- topology/examples/test_3d_gauss.py | 2 +- topology/pynest/hl_api.py | 20 +++++++++++++------- 12 files changed, 37 insertions(+), 28 deletions(-) diff --git a/libnestutil/logging_event.cpp b/libnestutil/logging_event.cpp index 8acf2647c2..50ad35203f 100644 --- a/libnestutil/logging_event.cpp +++ b/libnestutil/logging_event.cpp @@ -64,8 +64,8 @@ std::ostream& operator<<( std::ostream& out, const LoggingEvent& e ) out << "[INFO] "; break; case M_DEPRECATED: - out << "[INFO] "; - break; + out << "[INFO] "; + break; case M_WARNING: out << "[WARNING] "; break; diff --git a/pynest/examples/csa_topology_example.py b/pynest/examples/csa_topology_example.py index 0c1acec763..1c06cdc090 100644 --- a/pynest/examples/csa_topology_example.py +++ b/pynest/examples/csa_topology_example.py @@ -37,7 +37,7 @@ This example uses the function GetLeaves, which is deprecated. A deprecation warning is therefore released. For details about deprecated functions, see -documentation. +documentation. """ """ diff --git a/pynest/nest/lib/hl_api_helper.py b/pynest/nest/lib/hl_api_helper.py index 1bb15aa2da..f895fb5d3e 100644 --- a/pynest/nest/lib/hl_api_helper.py +++ b/pynest/nest/lib/hl_api_helper.py @@ -430,11 +430,12 @@ def turn_of_deprecation_warning(deprecated_func_name): Think thouroughly before use. The function should only be used as a way to make sure examples do not display deprecation warnings, that is, used in functions called from examples, and not as a way to make tedious - deprecation warnings dissapear. + deprecation warnings dissapear. - NB! Remember to always use turn_on_deprecation_warning(deprecated_func_name, - deprecation_bool, verbosity_level) after deprecated function is called, so - as to reset the deprecation warnings to their old value. + NB! Remember to always use turn_on_deprecation_warning( + deprecated_func_name, deprecation_bool, verbosity_level) after deprecated + function is called, so as to reset the deprecation warnings to their old + value. Parameters ---------- @@ -463,7 +464,7 @@ def turn_of_deprecation_warning(deprecated_func_name): def turn_on_deprecation_warning(deprecated_func_name, deprecation_bool, verbosity_level): """Return deprecation warning status back to original value. - + Whenever turn_of_deprecation_warning(deprecated_func_name) is used, this function must be called in order to reset to original status. @@ -480,5 +481,5 @@ def turn_on_deprecation_warning(deprecated_func_name, deprecation_bool, # Need to reset the deprecation warnings to their old value if verbosity_level <= 18: nest.set_verbosity(verbosity_level) - + _deprecation_warning[deprecated_func_name] = deprecation_bool diff --git a/pynest/nest/lib/hl_api_subnets.py b/pynest/nest/lib/hl_api_subnets.py index 3081e1f3bb..f8558ca738 100644 --- a/pynest/nest/lib/hl_api_subnets.py +++ b/pynest/nest/lib/hl_api_subnets.py @@ -52,11 +52,13 @@ def PrintNetwork(depth=1, subnet=None): # Turn off deprecation warning on Python and SLI level as users # shouldn't change implementation of PrintNetwork, it is done by the # developers. - deprecation_bool, verbosity_level = turn_of_deprecation_warning('CurrentSubnet') + deprecation_bool, verbosity_level = turn_of_deprecation_warning( + 'CurrentSubnet') subnet = CurrentSubnet() # Need to reset the deprecation warning to its old value - turn_on_deprecation_warning('CurrentSubnet', deprecation_bool, verbosity_level) - + turn_on_deprecation_warning('CurrentSubnet', deprecation_bool, + verbosity_level) + elif len(subnet) > 1: raise NESTError("PrintNetwork() expects exactly one GID.") diff --git a/sli/interpret.cc b/sli/interpret.cc index 4a17be29d3..90465dd794 100644 --- a/sli/interpret.cc +++ b/sli/interpret.cc @@ -829,7 +829,7 @@ SLIInterpreter::message( int level, else if ( level >= M_WARNING ) message( std::cout, M_WARNING_NAME, from, text, errorname ); else if ( level >= M_DEPRECATED ) - message( std::cout, M_DEPRECATED_NAME, from, text, errorname ); + message( std::cout, M_DEPRECATED_NAME, from, text, errorname ); else if ( level >= M_INFO ) message( std::cout, M_INFO_NAME, from, text, errorname ); else if ( level >= M_STATUS ) diff --git a/sli/interpret.h b/sli/interpret.h index 284cb315fa..3200a7957f 100644 --- a/sli/interpret.h +++ b/sli/interpret.h @@ -175,7 +175,7 @@ class SLIInterpreter //! Predefined error level for informational messages static const int M_INFO; static const int M_DEPRECATED; //!< Predefined error level for deprecation - //!< warnings + //!< warnings static const int M_WARNING; //!< Predefined error level for warning messages static const int M_ERROR; //!< Predefined error level for error messages static const int M_FATAL; //!< Predefined error level for failure messages diff --git a/topology/examples/ctx_2n.py b/topology/examples/ctx_2n.py index b84bde3574..1135cf4428 100644 --- a/topology/examples/ctx_2n.py +++ b/topology/examples/ctx_2n.py @@ -30,7 +30,7 @@ This example uses the function GetLeaves, which is deprecated. A deprecation warning is therefore released. For details about deprecated functions, see -documentation. +documentation. ''' import nest diff --git a/topology/examples/hill_tononi_Vp.py b/topology/examples/hill_tononi_Vp.py index 72753c5bce..dedc1e5ca1 100644 --- a/topology/examples/hill_tononi_Vp.py +++ b/topology/examples/hill_tononi_Vp.py @@ -144,9 +144,9 @@ # ! **Note:** By default, the script does not show any graphics. # ! Set ``SHOW_FIGURES`` to ``True`` to activate graphics. -# ! This example uses the function GetLeaves, which is deprecated. A deprecation -# ! warning is therefore released. For details about deprecated functions, see -# ! documentation. +# ! This example uses the function GetLeaves, which is deprecated. A +# ! deprecation warning is therefore released. For details about deprecated +# ! functions, see documentation. import pylab diff --git a/topology/examples/test_3d.py b/topology/examples/test_3d.py index a8079915d6..fa4a51c9c8 100644 --- a/topology/examples/test_3d.py +++ b/topology/examples/test_3d.py @@ -30,7 +30,7 @@ This example uses the function GetChildren, which is deprecated. A deprecation warning is therefore released. For details about deprecated functions, see -documentation. +documentation. ''' import nest diff --git a/topology/examples/test_3d_exp.py b/topology/examples/test_3d_exp.py index ca83ec191f..35e1e80d4b 100644 --- a/topology/examples/test_3d_exp.py +++ b/topology/examples/test_3d_exp.py @@ -30,7 +30,7 @@ This example uses the function GetChildren, which is deprecated. A deprecation warning is therefore released. For details about deprecated functions, see -documentation. +documentation. ''' import nest diff --git a/topology/examples/test_3d_gauss.py b/topology/examples/test_3d_gauss.py index ada2f20880..a00c788bce 100644 --- a/topology/examples/test_3d_gauss.py +++ b/topology/examples/test_3d_gauss.py @@ -30,7 +30,7 @@ This example uses the function GetChildren, which is deprecated. A deprecation warning is therefore released. For details about deprecated functions, see -documentation. +documentation. ''' import nest diff --git a/topology/pynest/hl_api.py b/topology/pynest/hl_api.py index b3f5dd0993..5acb19eec4 100644 --- a/topology/pynest/hl_api.py +++ b/topology/pynest/hl_api.py @@ -1622,15 +1622,17 @@ def GetTargetNodes(sources, tgt_layer, tgt_model=None, syn_model=None): # Turn off deprecation warning on Python and SLI level as users # shouldn't change implementation of GetTargetNodes, it is done by the # developers. - deprecation_bool, verbosity_level = nest.turn_of_deprecation_warning('GetLeaves') - + deprecation_bool, verbosity_level = nest.turn_of_deprecation_warning( + 'GetLeaves') + # obtain local nodes in target layer, to pass to GetConnections tgt_nodes = nest.GetLeaves(tgt_layer, properties={ 'model': tgt_model} if tgt_model else None, local_only=True)[0] # Need to reset the deprecation warning to its old value - nest.turn_on_deprecation_warning('GetLeaves', deprecation_bool, verbosity_level) + nest.turn_on_deprecation_warning('GetLeaves', deprecation_bool, + verbosity_level) conns = nest.GetConnections(sources, tgt_nodes, synapse_model=syn_model) @@ -1805,11 +1807,13 @@ def PlotLayer(layer, fig=None, nodecolor='b', nodesize=20): # Turn off deprecation warning on Python and SLI level as users # shouldn't change implementation of PrintNetwork, it is done by the # developers. - deprecation_bool, verbosity_level = nest.turn_of_deprecation_warning('GetChildren') + deprecation_bool, verbosity_level = nest.turn_of_deprecation_warning( + 'GetChildren') # extract position information, transpose to list of x and y positions xpos, ypos = zip(*GetPosition(nest.GetChildren(layer)[0])) # Need to reset the deprecation warning to its old value - nest.turn_on_deprecation_warning('GetCildren', deprecation_bool, verbosity_level) + nest.turn_on_deprecation_warning('GetCildren', deprecation_bool, + verbosity_level) if fig is None: fig = plt.figure() @@ -1828,11 +1832,13 @@ def PlotLayer(layer, fig=None, nodecolor='b', nodesize=20): # Turn off deprecation warning on Python and SLI level as users # shouldn't change implementation of PrintNetwork, it is done by the # developers. - deprecation_bool, verbosity_level = nest.turn_of_deprecation_warning('GetChildren') + deprecation_bool, verbosity_level = nest.turn_of_deprecation_warning( + 'GetChildren') # extract position information, transpose to list of x,y,z positions pos = zip(*GetPosition(nest.GetChildren(layer)[0])) # Need to reset the deprecation warning to its old value - nest.turn_on_deprecation_warning('GetChildren', deprecation_bool, verbosity_level) + nest.turn_on_deprecation_warning('GetChildren', deprecation_bool, + verbosity_level) if fig is None: fig = plt.figure() From a8f5447c894cef06e2e407e2b7383ed697bd2000 Mon Sep 17 00:00:00 2001 From: Stine Vennemo Date: Fri, 16 Dec 2016 09:31:58 +0100 Subject: [PATCH 12/16] Fixed formatting and made sure tests go through --- models/modelsmodule.cpp | 2 -- pynest/nest/lib/hl_api_helper.py | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/models/modelsmodule.cpp b/models/modelsmodule.cpp index a4f36190b9..4987679228 100644 --- a/models/modelsmodule.cpp +++ b/models/modelsmodule.cpp @@ -354,8 +354,6 @@ ModelsModule::init( SLIInterpreter* ) "aeif_cond_beta_multisynapse" ); kernel().model_manager.register_node_model< aeif_cond_alpha_multisynapse >( "aeif_cond_alpha_multisynapse" ); - kernel().model_manager.register_node_model< aeif_cond_alpha_multisynapse >( - "aeif_cond_alpha_multisynapse" ); #endif // This version of the AdEx model does not depend on GSL. diff --git a/pynest/nest/lib/hl_api_helper.py b/pynest/nest/lib/hl_api_helper.py index f895fb5d3e..f5eaaacba8 100644 --- a/pynest/nest/lib/hl_api_helper.py +++ b/pynest/nest/lib/hl_api_helper.py @@ -425,7 +425,8 @@ def model_deprecation_warning(model): def turn_of_deprecation_warning(deprecated_func_name): - """Turns of deprecation warnings on SLI and Python level for given function. + """Turns of deprecation warnings on SLI and Python level for given + function. Think thouroughly before use. The function should only be used as a way to make sure examples do not display deprecation warnings, that is, used in From e97933c29f2c477cee3754edb2903205a34248f9 Mon Sep 17 00:00:00 2001 From: Stine Vennemo Date: Fri, 16 Dec 2016 14:19:57 +0100 Subject: [PATCH 13/16] A few language fixes. --- pynest/examples/csa_topology_example.py | 2 +- pynest/nest/lib/hl_api_helper.py | 8 ++++---- pynest/nest/lib/hl_api_subnets.py | 2 +- topology/examples/ctx_2n.py | 2 +- topology/examples/hill_tononi_Vp.py | 2 +- topology/examples/test_3d.py | 2 +- topology/examples/test_3d_exp.py | 2 +- topology/examples/test_3d_gauss.py | 2 +- topology/pynest/hl_api.py | 6 +++--- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pynest/examples/csa_topology_example.py b/pynest/examples/csa_topology_example.py index 1c06cdc090..cd74541682 100644 --- a/pynest/examples/csa_topology_example.py +++ b/pynest/examples/csa_topology_example.py @@ -36,7 +36,7 @@ For a related example, see csa_example.py This example uses the function GetLeaves, which is deprecated. A deprecation -warning is therefore released. For details about deprecated functions, see +warning is therefore issued. For details about deprecated functions, see documentation. """ diff --git a/pynest/nest/lib/hl_api_helper.py b/pynest/nest/lib/hl_api_helper.py index f5eaaacba8..969c9ca979 100644 --- a/pynest/nest/lib/hl_api_helper.py +++ b/pynest/nest/lib/hl_api_helper.py @@ -404,7 +404,7 @@ def broadcast(item, length, allowed_types, name="item"): def model_deprecation_warning(model): """Checks whether the model is to be removed in a future verstion of NEST. - If so, a deprecation warning is released. + If so, a deprecation warning is issued. Parameters ---------- @@ -424,8 +424,8 @@ def model_deprecation_warning(model): warnings.warn('\n' + text) -def turn_of_deprecation_warning(deprecated_func_name): - """Turns of deprecation warnings on SLI and Python level for given +def turn_off_deprecation_warning(deprecated_func_name): + """Turns off deprecation warnings on SLI and Python level for given function. Think thouroughly before use. The function should only be used as a way to @@ -466,7 +466,7 @@ def turn_on_deprecation_warning(deprecated_func_name, deprecation_bool, verbosity_level): """Return deprecation warning status back to original value. - Whenever turn_of_deprecation_warning(deprecated_func_name) is used, this + Whenever turn_off_deprecation_warning(deprecated_func_name) is used, this function must be called in order to reset to original status. Parameters diff --git a/pynest/nest/lib/hl_api_subnets.py b/pynest/nest/lib/hl_api_subnets.py index f8558ca738..4154c19e82 100644 --- a/pynest/nest/lib/hl_api_subnets.py +++ b/pynest/nest/lib/hl_api_subnets.py @@ -52,7 +52,7 @@ def PrintNetwork(depth=1, subnet=None): # Turn off deprecation warning on Python and SLI level as users # shouldn't change implementation of PrintNetwork, it is done by the # developers. - deprecation_bool, verbosity_level = turn_of_deprecation_warning( + deprecation_bool, verbosity_level = turn_off_deprecation_warning( 'CurrentSubnet') subnet = CurrentSubnet() # Need to reset the deprecation warning to its old value diff --git a/topology/examples/ctx_2n.py b/topology/examples/ctx_2n.py index 1135cf4428..2181bf946e 100644 --- a/topology/examples/ctx_2n.py +++ b/topology/examples/ctx_2n.py @@ -29,7 +29,7 @@ Hans Ekkehard Plesser, UMB This example uses the function GetLeaves, which is deprecated. A deprecation -warning is therefore released. For details about deprecated functions, see +warning is therefore issued. For details about deprecated functions, see documentation. ''' diff --git a/topology/examples/hill_tononi_Vp.py b/topology/examples/hill_tononi_Vp.py index dedc1e5ca1..3d5de8dadf 100644 --- a/topology/examples/hill_tononi_Vp.py +++ b/topology/examples/hill_tononi_Vp.py @@ -145,7 +145,7 @@ # ! Set ``SHOW_FIGURES`` to ``True`` to activate graphics. # ! This example uses the function GetLeaves, which is deprecated. A -# ! deprecation warning is therefore released. For details about deprecated +# ! deprecation warning is therefore issued. For details about deprecated # ! functions, see documentation. diff --git a/topology/examples/test_3d.py b/topology/examples/test_3d.py index fa4a51c9c8..1ed5bb88ac 100644 --- a/topology/examples/test_3d.py +++ b/topology/examples/test_3d.py @@ -29,7 +29,7 @@ Hans Ekkehard Plesser, UMB This example uses the function GetChildren, which is deprecated. A deprecation -warning is therefore released. For details about deprecated functions, see +warning is therefore issued. For details about deprecated functions, see documentation. ''' diff --git a/topology/examples/test_3d_exp.py b/topology/examples/test_3d_exp.py index 35e1e80d4b..812696845c 100644 --- a/topology/examples/test_3d_exp.py +++ b/topology/examples/test_3d_exp.py @@ -29,7 +29,7 @@ Hans Ekkehard Plesser, UMB This example uses the function GetChildren, which is deprecated. A deprecation -warning is therefore released. For details about deprecated functions, see +warning is therefore issued. For details about deprecated functions, see documentation. ''' diff --git a/topology/examples/test_3d_gauss.py b/topology/examples/test_3d_gauss.py index a00c788bce..6390162a0d 100644 --- a/topology/examples/test_3d_gauss.py +++ b/topology/examples/test_3d_gauss.py @@ -29,7 +29,7 @@ Hans Ekkehard Plesser, UMB This example uses the function GetChildren, which is deprecated. A deprecation -warning is therefore released. For details about deprecated functions, see +warning is therefore issued. For details about deprecated functions, see documentation. ''' diff --git a/topology/pynest/hl_api.py b/topology/pynest/hl_api.py index 5acb19eec4..bfd46562fd 100644 --- a/topology/pynest/hl_api.py +++ b/topology/pynest/hl_api.py @@ -1622,7 +1622,7 @@ def GetTargetNodes(sources, tgt_layer, tgt_model=None, syn_model=None): # Turn off deprecation warning on Python and SLI level as users # shouldn't change implementation of GetTargetNodes, it is done by the # developers. - deprecation_bool, verbosity_level = nest.turn_of_deprecation_warning( + deprecation_bool, verbosity_level = nest.turn_off_deprecation_warning( 'GetLeaves') # obtain local nodes in target layer, to pass to GetConnections @@ -1807,7 +1807,7 @@ def PlotLayer(layer, fig=None, nodecolor='b', nodesize=20): # Turn off deprecation warning on Python and SLI level as users # shouldn't change implementation of PrintNetwork, it is done by the # developers. - deprecation_bool, verbosity_level = nest.turn_of_deprecation_warning( + deprecation_bool, verbosity_level = nest.turn_off_deprecation_warning( 'GetChildren') # extract position information, transpose to list of x and y positions xpos, ypos = zip(*GetPosition(nest.GetChildren(layer)[0])) @@ -1832,7 +1832,7 @@ def PlotLayer(layer, fig=None, nodecolor='b', nodesize=20): # Turn off deprecation warning on Python and SLI level as users # shouldn't change implementation of PrintNetwork, it is done by the # developers. - deprecation_bool, verbosity_level = nest.turn_of_deprecation_warning( + deprecation_bool, verbosity_level = nest.turn_off_deprecation_warning( 'GetChildren') # extract position information, transpose to list of x,y,z positions pos = zip(*GetPosition(nest.GetChildren(layer)[0])) From d0531429f4faebbf6930efdb6a70ad081d798b4c Mon Sep 17 00:00:00 2001 From: Stine Vennemo Date: Fri, 16 Dec 2016 14:26:09 +0100 Subject: [PATCH 14/16] I was a bit quick with copy paste of comments. PrintNetwork -> PlotLayer in 2 comments. --- topology/pynest/hl_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/pynest/hl_api.py b/topology/pynest/hl_api.py index bfd46562fd..89c399cde8 100644 --- a/topology/pynest/hl_api.py +++ b/topology/pynest/hl_api.py @@ -1805,7 +1805,7 @@ def PlotLayer(layer, fig=None, nodecolor='b', nodesize=20): xctr, yctr = nest.GetStatus(layer, 'topology')[0]['center'] # Turn off deprecation warning on Python and SLI level as users - # shouldn't change implementation of PrintNetwork, it is done by the + # shouldn't change implementation of PlotLayer, it is done by the # developers. deprecation_bool, verbosity_level = nest.turn_off_deprecation_warning( 'GetChildren') @@ -1830,7 +1830,7 @@ def PlotLayer(layer, fig=None, nodecolor='b', nodesize=20): from mpl_toolkits.mplot3d import Axes3D # Turn off deprecation warning on Python and SLI level as users - # shouldn't change implementation of PrintNetwork, it is done by the + # shouldn't change implementation of PlotLayer, it is done by the # developers. deprecation_bool, verbosity_level = nest.turn_off_deprecation_warning( 'GetChildren') From f11339853e72aaa871e8ab9ac472a24fed1eff17 Mon Sep 17 00:00:00 2001 From: Stine Vennemo Date: Wed, 21 Dec 2016 11:03:15 +0100 Subject: [PATCH 15/16] Small spelling error, verstion -> version. --- pynest/nest/lib/hl_api_helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pynest/nest/lib/hl_api_helper.py b/pynest/nest/lib/hl_api_helper.py index 969c9ca979..b41eb68d0f 100644 --- a/pynest/nest/lib/hl_api_helper.py +++ b/pynest/nest/lib/hl_api_helper.py @@ -418,7 +418,7 @@ def model_deprecation_warning(model): if model in deprecated_models: text = "The {0} model is deprecated and will be removed in a \ - future verstion of NEST, use {1} instead\ + future version of NEST, use {1} instead\ ".format(model, deprecated_models[model]) text = get_wrapped_text(text) warnings.warn('\n' + text) From 76f2b55875a499d9d367eab1f79b1bd837f0a864 Mon Sep 17 00:00:00 2001 From: Stine Vennemo Date: Mon, 2 Jan 2017 09:56:29 +0100 Subject: [PATCH 16/16] Made requested changes. --- lib/sli/nest-init.sli | 6 +++--- libnestutil/logging_event.cpp | 2 +- models/modelsmodule.cpp | 2 +- pynest/nest/lib/hl_api_connections.py | 4 ++-- pynest/nest/lib/hl_api_helper.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/sli/nest-init.sli b/lib/sli/nest-init.sli index d573e1b9ea..44de9cfb3b 100644 --- a/lib/sli/nest-init.sli +++ b/lib/sli/nest-init.sli @@ -741,7 +741,7 @@ Options << >> begin /LayoutNetwork /deprecation_warning GetOption true eq { - (Sli function LayoutNetwork is deprecated in NEST 3.0.) M_DEPRECATED message + (SLI function LayoutNetwork is deprecated in NEST 3.0.) M_DEPRECATED message /LayoutNetwork << /deprecation_warning false >> SetOptions } if /val Set @@ -786,7 +786,7 @@ Options << >> begin /LayoutNetwork /deprecation_warning GetOption true eq { - (Sli function LayoutNetwork is deprecated in NEST 3.0.) M_DEPRECATED message + (SLI function LayoutNetwork is deprecated in NEST 3.0.) M_DEPRECATED message /LayoutNetwork << /deprecation_warning false >> SetOptions } if size /n_dim Set @@ -1268,7 +1268,7 @@ Options << >> begin /GetNetwork /deprecation_warning GetOption true eq { - (Sli function GetNetwork is deprecated in NEST 3.0.) M_DEPRECATED message + (SLI function GetNetwork is deprecated in NEST 3.0.) M_DEPRECATED message /GetNetwork << /deprecation_warning false >> SetOptions } if /depth Set diff --git a/libnestutil/logging_event.cpp b/libnestutil/logging_event.cpp index 50ad35203f..805bed0afd 100644 --- a/libnestutil/logging_event.cpp +++ b/libnestutil/logging_event.cpp @@ -64,7 +64,7 @@ std::ostream& operator<<( std::ostream& out, const LoggingEvent& e ) out << "[INFO] "; break; case M_DEPRECATED: - out << "[INFO] "; + out << "[DEPRECATED] "; break; case M_WARNING: out << "[WARNING] "; diff --git a/models/modelsmodule.cpp b/models/modelsmodule.cpp index 4987679228..47e21598a4 100644 --- a/models/modelsmodule.cpp +++ b/models/modelsmodule.cpp @@ -360,7 +360,7 @@ ModelsModule::init( SLIInterpreter* ) kernel().model_manager.register_node_model< aeif_cond_alpha_RK5 >( "aeif_cond_alpha_RK5", /*private_model*/ false, - /*deprecation_model*/ "NEST 3.0" ); + /*deprecation_info*/ "NEST 3.0" ); #ifdef HAVE_MUSIC //// proxies for inter-application communication using MUSIC diff --git a/pynest/nest/lib/hl_api_connections.py b/pynest/nest/lib/hl_api_connections.py index edda2cd5f3..8af1675c54 100644 --- a/pynest/nest/lib/hl_api_connections.py +++ b/pynest/nest/lib/hl_api_connections.py @@ -352,8 +352,8 @@ def Connect(pre, post, conn_spec=None, syn_spec=None, model=None): @check_stack -@deprecated('', 'DataConnect is deprecated and will be removed in NEST3. Use \ -Connect() with one_to_one rule instead.') +@deprecated('', 'DataConnect is deprecated and will be removed in NEST 3.0.\ +Use Connect() with one_to_one rule instead.') def DataConnect(pre, params=None, model="static_synapse"): """Connect neurons from lists of connection data. diff --git a/pynest/nest/lib/hl_api_helper.py b/pynest/nest/lib/hl_api_helper.py index b41eb68d0f..741dc9db3d 100644 --- a/pynest/nest/lib/hl_api_helper.py +++ b/pynest/nest/lib/hl_api_helper.py @@ -418,7 +418,7 @@ def model_deprecation_warning(model): if model in deprecated_models: text = "The {0} model is deprecated and will be removed in a \ - future version of NEST, use {1} instead\ + future version of NEST, use {1} instead.\ ".format(model, deprecated_models[model]) text = get_wrapped_text(text) warnings.warn('\n' + text)