Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
super(SignificanceVertexPartitionTest, self).setUp();
self.partition_type = leidenalg.SignificanceVertexPartition;
def test_aggregate_partition(self, graph):
if 'weight' in graph.es.attributes() and self.partition_type != leidenalg.SignificanceVertexPartition:
partition = self.partition_type(graph, weights='weight');
else:
partition = self.partition_type(graph);
self.optimiser.move_nodes(partition);
aggregate_partition = partition.aggregate_partition();
self.assertAlmostEqual(
partition.quality(),
aggregate_partition.quality(),
places=5,
msg='Quality not equal for aggregate partition.');
self.optimiser.move_nodes(aggregate_partition);
partition.from_coarse_partition(aggregate_partition);
self.assertAlmostEqual(
partition.quality(),
aggregate_partition.quality(),
places=5,
if graph is None:
knn_conn_mat = self._sdm.s_knn_connectivity_matrix(
k=k, use_pca=use_pca, use_hnsw=use_hnsw,
index_params=index_params, query_params=query_params,
verbose=verbose)
graph = SampleDistanceMatrix.knn_conn_mat_to_aff_graph(
knn_conn_mat, aff_scale=aff_scale)
if partition_method == "RBConfigurationVertexPartition":
la_part_cls = la.RBConfigurationVertexPartition
elif partition_method == "RBERVertexPartition":
la_part_cls = la.RBERVertexPartition
elif partition_method == "CPMVertexPartition":
la_part_cls = la.CPMVertexPartition
elif partition_method == "SignificanceVertexPartition":
la_part_cls = la.SignificanceVertexPartition
elif partition_method == "SurpriseVertexPartition":
la_part_cls = la.SurpriseVertexPartition
else:
raise ValueError(
"Unknown partition method: {}".format(partition_method))
la_res = la.find_partition(graph, la.RBConfigurationVertexPartition,
seed=random_state, weights='weight',
resolution_parameter=resolution)
# keep track of results and parameters
self._graph = graph
self._la_res = la_res
self._labs = la_res.membership
self._k = k
self._use_pca = use_pca
self._use_hnsw = use_hnsw