From d187a587d87a0a3ef11198351693aa3685a3da8a Mon Sep 17 00:00:00 2001 From: Nick Tolley Date: Mon, 19 Apr 2021 20:46:34 -0400 Subject: [PATCH] Rename update_probability to drop --- examples/plot_connectivity.py | 2 +- hnn_core/network.py | 6 +++--- hnn_core/tests/test_network.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/plot_connectivity.py b/examples/plot_connectivity.py index 978744cdd..e78748cf1 100644 --- a/examples/plot_connectivity.py +++ b/examples/plot_connectivity.py @@ -58,7 +58,7 @@ # all the same cell type allowing for easy modifications. for conn in net.connectivity: if conn['src_type'] == 'L2_basket': - conn.update_probability(0.1) + conn.drop(0.1) net_remove = net.copy() dpl_remove = simulate_dipole(net_remove, n_trials=1) diff --git a/hnn_core/network.py b/hnn_core/network.py index 0b805de1b..d7e6f34b8 100644 --- a/hnn_core/network.py +++ b/hnn_core/network.py @@ -1074,7 +1074,7 @@ def add_connection(self, src_gids, target_gids, loc, receptor, conn['nc_dict'][key] = item if probability != 1.0: - conn.update_probability(probability) + conn.drop(probability) conn['probability'] = probability self.connectivity.append(deepcopy(conn)) @@ -1178,7 +1178,7 @@ def __repr__(self): return entr - def update_probability(self, probability): + def drop(self, probability): """Remove/keep a random subset of connections. Parameters @@ -1206,7 +1206,7 @@ def update_probability(self, probability): target_src_pair in self['gid_pairs'].values()]) n_connections = np.round( len(all_connections) * probability).astype(int) - print(len(all_connections), n_connections) + # Select a random subset of connections to retain. new_connections = np.random.choice( range(len(all_connections)), n_connections, replace=False) diff --git a/hnn_core/tests/test_network.py b/hnn_core/tests/test_network.py index 7a6cc55ee..e682587ea 100644 --- a/hnn_core/tests/test_network.py +++ b/hnn_core/tests/test_network.py @@ -231,7 +231,7 @@ def test_network(): n_connections = np.sum( [len(t_gids) for t_gids in net.connectivity[0]['gid_pairs'].values()]) - net.connectivity[0].update_probability(0.5) + net.connectivity[0].drop(0.5) n_connections_new = np.sum( [len(t_gids) for t_gids in net.connectivity[0]['gid_pairs'].values()])