Skip to content

Commit

Permalink
Merging master
Browse files Browse the repository at this point in the history
  • Loading branch information
JanVogelsang committed Jun 24, 2024
1 parent e5223ef commit 5e88d27
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 33 deletions.
1 change: 0 additions & 1 deletion models/cm_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Compartment::Compartment( const long compartment_index, const long parent_index
compartment_currents = CompartmentCurrents( v_comp );
}

nest::Compartment::Compartment( const long compartment_index,
Compartment::Compartment( const long compartment_index,
const long parent_index,
const DictionaryDatum& compartment_params )
Expand Down
2 changes: 1 addition & 1 deletion models/eprop_learning_signal_connection_bsshslm_2020.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class eprop_learning_signal_connection_bsshslm_2020 : public Connection< targeti

//! Check if the target accepts the event and receptor type requested by the sender.
void
check_connection( Node& s, Node& t, size_t receptor_type, const CommonPropertiesType& )
check_connection( Node& s, Node& t, size_t receptor_type, const synindex, const CommonPropertiesType& )
{
LearningSignalConnectionEvent ge;

Expand Down
8 changes: 5 additions & 3 deletions models/eprop_synapse_bsshslm_2020.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class eprop_synapse_bsshslm_2020 : public Connection< targetidentifierT >
//! Move assignment operator
eprop_synapse_bsshslm_2020& operator=( eprop_synapse_bsshslm_2020&& );

using ConnectionBase::get_delay;
using ConnectionBase::get_delay_ms;
using ConnectionBase::get_delay_steps;
using ConnectionBase::get_rport;
using ConnectionBase::get_target;
Expand Down Expand Up @@ -295,7 +295,8 @@ class eprop_synapse_bsshslm_2020 : public Connection< targetidentifierT >
*
* @note This sets the optimizer_ member.
*/
void check_connection( Node& s, Node& t, size_t receptor_type, const CommonPropertiesType& cp );
void
check_connection( Node& s, Node& t, size_t receptor_type, const synindex syn_id, const CommonPropertiesType& cp );

//! Set the synaptic weight to the provided value.
void
Expand Down Expand Up @@ -470,6 +471,7 @@ inline void
eprop_synapse_bsshslm_2020< targetidentifierT >::check_connection( Node& s,
Node& t,
size_t receptor_type,
const synindex syn_id,
const CommonPropertiesType& cp )
{
// When we get here, delay has been set so we can check it.
Expand All @@ -479,7 +481,7 @@ eprop_synapse_bsshslm_2020< targetidentifierT >::check_connection( Node& s,
}

ConnTestDummyNode dummy_target;
ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
ConnectionBase::check_connection_( dummy_target, s, t, syn_id, receptor_type );

t.register_eprop_connection();

Expand Down
6 changes: 4 additions & 2 deletions nestkernel/connector_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,13 @@ class GenericConnectorModel : public ConnectorModel

ConnectionT default_connection_;
size_t receptor_type_;
synindex syn_id_;

public:
GenericConnectorModel( const std::string name )
: ConnectorModel( name, ConnectionT::properties )
, receptor_type_( 0 )
, syn_id_( invalid_synindex )
{
}

Expand All @@ -171,6 +173,7 @@ class GenericConnectorModel : public ConnectorModel
, cp_( cm.cp_ )
, default_connection_( cm.default_connection_ )
, receptor_type_( cm.receptor_type_ )
, syn_id_( cm.syn_id_ )
{
}

Expand Down Expand Up @@ -215,8 +218,7 @@ class GenericConnectorModel : public ConnectorModel

private:
void used_default_delay();

}; // GenericConnectorModel
};

} // namespace nest

Expand Down
12 changes: 10 additions & 2 deletions nestkernel/connector_model_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace nest
// double get_default_delay(const GenericConnectorModel<ConnectionT> &cm)
// {
// //std::cout << "standard implementation of get_default_delay" << std::endl;
// return cm.get_default_connection().get_delay();
// return cm.get_default_connection().get_delay_ms();
// }


Expand All @@ -63,6 +63,7 @@ ConnectorModel*
GenericConnectorModel< ConnectionT >::clone( std::string name, synindex syn_id ) const
{
ConnectorModel* new_cm = new GenericConnectorModel( *this, name ); // calls copy construtor
new_cm->set_syn_id( syn_id );

const bool is_primary = new_cm->has_property( ConnectionModelProperties::IS_PRIMARY );
if ( not is_primary )
Expand Down Expand Up @@ -201,7 +202,14 @@ template < typename ConnectionT >
size_t
GenericConnectorModel< ConnectionT >::get_syn_id() const
{
return default_connection_.get_syn_id();
return syn_id_;
}

template < typename ConnectionT >
void
GenericConnectorModel< ConnectionT >::set_syn_id( synindex syn_id )
{
syn_id_ = syn_id;
}

template < typename ConnectionT >
Expand Down
1 change: 1 addition & 0 deletions nestkernel/model_manager_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ ModelManager::register_specific_connection_model_( const std::string& name )
#pragma omp parallel
{
ConnectorModel* conn_model = new GenericConnectorModel< CompleteConnectionT >( name );
conn_model->set_syn_id( new_syn_id );
if ( not conn_model->has_property( ConnectionModelProperties::IS_PRIMARY ) )
{
conn_model->get_secondary_event()->add_syn_id( new_syn_id );
Expand Down
3 changes: 2 additions & 1 deletion pynest/nest/lib/hl_api_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ def Connect(pre, post, conn_spec=None, syn_spec=None, return_synapsecollection=F
else:
syn_param_values = None

connect_arrays(pre, post, weights, delays, axonal_delays, synapse_model, reduced_processed_syn_spec.keys(), syn_param_values)
connect_arrays(pre, post, weights, delays, axonal_delays, synapse_model, reduced_processed_syn_spec.keys(),
syn_param_values)

return

Expand Down
46 changes: 23 additions & 23 deletions testsuite/pytests/test_stdp_pl_synapse_hom.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
except Exception:
DEBUG_PLOTS = False


# Defined here so we can use it in init_params() and in parametrization
RESOLUTION = 0.1 # [ms]

Expand Down Expand Up @@ -96,9 +95,9 @@ def do_nest_simulation_and_compare_to_reproduced_weight(self, fname_snip):
assert len(weight_by_nest) > 0

difference_matrix = (
t_weight_by_nest[t_weight_by_nest < self.simulation_duration].reshape(1, -1)
+ self.axonal_delay
- t_weight_reproduced_independently.reshape(-1, 1)
t_weight_by_nest[t_weight_by_nest < self.simulation_duration].reshape(1, -1)
+ self.axonal_delay
- t_weight_reproduced_independently.reshape(-1, 1)
)
pre_spike_reproduced_indices = np.abs(difference_matrix).argmin(axis=0)
time_differences = np.diagonal(difference_matrix[pre_spike_reproduced_indices])
Expand Down Expand Up @@ -218,7 +217,7 @@ def facilitate(w, Kplus):

def depress(w, Kminus):
new_weight = (
w - self.synapse_common_properties["alpha"] * self.synapse_common_properties["lambda"] * w * Kminus
w - self.synapse_common_properties["alpha"] * self.synapse_common_properties["lambda"] * w * Kminus
)
return new_weight if new_weight > 0.0 else 0.0

Expand Down Expand Up @@ -294,7 +293,7 @@ def depress(w, Kminus):
# if time when next pre-synaptic spike is being communicated is before post-synaptic spike
# occurs, a correction will be required in NEST
if (
t_next_pre_spike - RESOLUTION - self.axonal_delay + self.min_delay
t_next_pre_spike - RESOLUTION - self.axonal_delay + self.min_delay
) // self.min_delay * self.min_delay < t_next_post_spike:
allowed_to_deviate.append(True)
else:
Expand All @@ -307,15 +306,15 @@ def depress(w, Kminus):
# if the next post-synaptic spike occurs after the pre-synaptic is being communicated, but
# before the pre-synaptic spike arrives at the synapse, a correction will be required in NEST
if (
abs(t_next_post_spike - t_next_pre_spike) < eps
and (t_next_pre_spike - RESOLUTION - self.axonal_delay + self.min_delay)
// self.min_delay
* self.min_delay
< t_next_post_spike - self.dendritic_delay
abs(t_next_post_spike - t_next_pre_spike) < eps
and (t_next_pre_spike - RESOLUTION - self.axonal_delay + self.min_delay)
// self.min_delay
* self.min_delay
< t_next_post_spike - self.dendritic_delay
):
pass
elif (
t_next_pre_spike - RESOLUTION - self.axonal_delay + self.min_delay
t_next_pre_spike - RESOLUTION - self.axonal_delay + self.min_delay
) // self.min_delay * self.min_delay < t_last_post_spike:
allowed_to_deviate.append(True)
else:
Expand Down Expand Up @@ -349,16 +348,16 @@ def depress(w, Kminus):
return np.array(t_log), np.array(w_log), Kplus_log, Kminus_log, np.array(allowed_to_deviate)

def plot_weight_evolution(
self,
pre_spikes,
post_spikes,
t_log,
w_log,
Kpre_log=None,
Kpost_log=None,
pre_indices=slice(-1),
fname_snip="",
title_snip="",
self,
pre_spikes,
post_spikes,
t_log,
w_log,
Kpre_log=None,
Kpost_log=None,
pre_indices=slice(-1),
fname_snip="",
title_snip="",
):
if not DEBUG_PLOTS: # make pylint happy if no matplotlib
return
Expand Down Expand Up @@ -396,7 +395,8 @@ def plot_weight_evolution(
fig.savefig("./tmp/nest_stdp_pl_synapse_hom_test" + fname_snip + ".png", dpi=300)
plt.close(fig)

@pytest.mark.parametrize(["dend_delay", "ax_delay"], ((1.0, 0.0), (0.5, 0.5), (0.0, 1.0), (RESOLUTION, 0.0), (0.0, RESOLUTION)))
@pytest.mark.parametrize(["dend_delay", "ax_delay"],
((1.0, 0.0), (0.5, 0.5), (0.0, 1.0), (RESOLUTION, 0.0), (0.0, RESOLUTION)))
@pytest.mark.parametrize("model", ("iaf_psc_alpha",))
@pytest.mark.parametrize("min_delay", (1.0, 0.4, RESOLUTION))
@pytest.mark.parametrize("max_delay", (1.0, 3.0))
Expand Down

0 comments on commit 5e88d27

Please sign in to comment.