Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change in GetStructrualPlasticityStatus format #775

Merged
merged 7 commits into from Jul 11, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions nestkernel/sp_manager.cpp
Expand Up @@ -85,8 +85,6 @@ SPManager::get_status( DictionaryDatum& d )
{
DictionaryDatum sp_synapses = DictionaryDatum( new Dictionary() );
DictionaryDatum sp_synapse;


def< DictionaryDatum >(
d, names::structural_plasticity_synapses, sp_synapses );
for ( std::vector< SPBuilder* >::const_iterator i = sp_conn_builders_.begin();
Expand Down
12 changes: 9 additions & 3 deletions pynest/nest/lib/hl_api_simulation.py
Expand Up @@ -234,14 +234,20 @@ def SetStructuralPlasticityStatus(params):


@check_stack
def GetStructuralPlasticityStatus(params):
def GetStructuralPlasticityStatus(keys = None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No spaces around = in parameter lists.

"""Get the current structural plasticity parameters for the network
simulation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document the keys parameter.

"""

sps(params)
sps({})
sr('GetStructuralPlasticityStatus')
return spp()
d = spp()
if keys is None:
return d
elif is_literal(keys):
return d[keys]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, keys can only be a single key, so why the plural? And wouldn't it make more sense to allow a list of keys, as in GetStatus?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left it plural but allow now a list like in GetStatus :)

else:
raise TypeError("keys should be either empty or a string")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"should" is not a good term here, as it implies a recommendation, not a requirement, while we have strict requirements on the type of keys. Use "must" instead.



@check_stack
Expand Down
5 changes: 4 additions & 1 deletion pynest/nest/tests/test_sp/test_all.py
Expand Up @@ -29,6 +29,8 @@
from . import test_disconnect
from . import test_disconnect_multiple
from . import test_enable_multithread
from . import test_get_sp_status

HAVE_MPI = nest.sli_func("statusdict/have_mpi ::")
if HAVE_MPI:
print ("Testing with MPI")
Expand Down Expand Up @@ -60,9 +62,10 @@ def suite():
test_suite.addTest(test_growth_curves.suite())
test_suite.addTest(test_sp_manager.suite())
test_suite.addTest(test_synaptic_elements.suite())
test_suite.addTest(test_disconnect.suite())
#test_suite.addTest(test_disconnect.suite())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you commenting out the disconnection test? Either activate it again or delete the line entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a mistake, I will remove the comment it now.

test_suite.addTest(test_disconnect_multiple.suite())
test_suite.addTest(test_enable_multithread.suite())
test_suite.addTest(test_get_sp_status.suite())

return test_suite

Expand Down
90 changes: 90 additions & 0 deletions pynest/nest/tests/test_sp/test_get_sp_status.py
@@ -0,0 +1,90 @@
# -*- coding: utf-8 -*-
#
# test_get_sp_status.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 <http://www.gnu.org/licenses/>.

'''
Structural Plasticity GetStatus Test
-----------------------
This test shows how to use the GetStructuralPlasticityStatus function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test should rather show that the function works correctly. That it also illustrates how to use the function is rather a (welcome) side-effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will correct the text

'''


import nest
import unittest

__author__ = 'sdiaz'


class TestGetStructuralPlasticityStatus(unittest.TestCase):

neuron_model = 'iaf_psc_alpha'
nest.CopyModel('static_synapse', 'synapse_ex')
nest.SetDefaults('synapse_ex', {'weight': 1.0, 'delay': 1.0})
nest.SetStructuralPlasticityStatus({
'structural_plasticity_synapses': {
'synapse_ex': {
'model': 'synapse_ex',
'post_synaptic_element': 'Den_ex',
'pre_synaptic_element': 'Axon_ex',
},
}
})

growth_curve = {
'growth_curve': "gaussian",
'growth_rate': 0.0001, # (elements/ms)
'continuous': False,
'eta': 0.0, # Ca2+
'eps': 0.05
}

'''
Now we assign the growth curves to the corresponding synaptic elements
'''
synaptic_elements = {
'Den_ex': growth_curve,
'Den_in': growth_curve,
'Axon_ex': growth_curve,
}
nodes = nest.Create(neuron_model,
2,
{'synaptic_elements': synaptic_elements})

all = nest.GetStructuralPlasticityStatus()
print (all)
assert('structural_plasticity_synapses' in all)
assert('structural_plasticity_update_interval' in all)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you not testing the values here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want to know that the elements have been gathered by the call to get status but I can test the values too :)


sp_synapses = nest.GetStructuralPlasticityStatus('structural_plasticity_synapses')
print (sp_synapses)
assert('pre_synaptic_element' in sp_synapses['syn1'])
assert('post_synaptic_element' in sp_synapses['syn1'])

sp_interval = nest.GetStructuralPlasticityStatus('structural_plasticity_update_interval')
print (sp_interval)
assert(sp_interval == 1000)

def suite():
test_suite = unittest.makeSuite(TestGetStructuralPlasticityStatus, 'test')
return test_suite


if __name__ == '__main__':
unittest.main()