[med-svn] [Git][med-team/python-leidenalg][upstream] New upstream version 0.8.8

Nilesh Patra (@nilesh) gitlab at salsa.debian.org
Tue Oct 19 12:23:44 BST 2021



Nilesh Patra pushed to branch upstream at Debian Med / python-leidenalg


Commits:
eefd31db by Nilesh Patra at 2021-10-19T16:45:11+05:30
New upstream version 0.8.8
- - - - -


4 changed files:

- CHANGELOG
- doc/source/advanced.rst
- src/leidenalg/MutableVertexPartition.cpp
- src/leidenalg/python_optimiser_interface.cpp


Changes:

=====================================
CHANGELOG
=====================================
@@ -1,3 +1,7 @@
+0.8.8
+- Corrected relabeling bug (PR #82)
+- Improved error handling, avoiding some crashses (issue #81)
+
 0.8.7
 - Improved numerical stability
 


=====================================
doc/source/advanced.rst
=====================================
@@ -222,7 +222,7 @@ We can then only update the community assignments for the new nodes as follows
 >>> new_partition = la.CPMVertexPartition(G2, new_membership,
 ...                                       resolution_parameter=partition.resolution_parameter)
 ... is_membership_fixed = [i < G.vcount() for i in range(G2.vcount())]
->>> diff = optimiser.optimise_partition(partition, is_membership_fixed=is_membership_fixed)
+>>> diff = optimiser.optimise_partition(new_partition, is_membership_fixed=is_membership_fixed)
 
 In this example we used :class:`~leidenalg.CPMVertexPartition`. but any other
 ``VertexPartition`` would work as well.


=====================================
src/leidenalg/MutableVertexPartition.cpp
=====================================
@@ -286,9 +286,10 @@ void MutableVertexPartition::relabel_communities(vector<size_t> const& new_comm_
   vector<size_t> new_csize(nbcomms, 0);
   vector<size_t> new_cnodes(nbcomms, 0);
 
+  // Relabel community admin
   for (size_t c = 0; c < new_comm_id.size(); c++) {
     size_t new_c = new_comm_id[c];
-    if (this->_csize[c] > 0) {
+    if (this->_cnodes[c] > 0) {
       new_total_weight_in_comm[new_c] = this->_total_weight_in_comm[c];
       new_total_weight_from_comm[new_c] = this->_total_weight_from_comm[c];
       new_total_weight_to_comm[new_c] = this->_total_weight_to_comm[c];
@@ -305,7 +306,7 @@ void MutableVertexPartition::relabel_communities(vector<size_t> const& new_comm_
 
   this->_empty_communities.clear();
   for (size_t c = 0; c < nbcomms; c++) {
-    if (this->_csize[c] == 0) {
+    if (this->_cnodes[c] == 0) {
       this->_empty_communities.push_back(c);
     }
   }


=====================================
src/leidenalg/python_optimiser_interface.cpp
=====================================
@@ -83,7 +83,8 @@ extern "C"
       size_t nb_is_membership_fixed = PyList_Size(py_is_membership_fixed);
       if (nb_is_membership_fixed != n)
       {
-        throw Exception("Node size vector not the same size as the number of nodes.");
+        PyErr_SetString(PyExc_ValueError, "Node size vector not the same size as the number of nodes.");
+        return NULL;
       }
 
       for (size_t v = 0; v < n; v++)
@@ -167,7 +168,10 @@ extern "C"
       }
 
       if (isnan(layer_weights[layer]))
-        throw Exception("Cannot accept NaN weights.");
+      {
+        PyErr_SetString(PyExc_TypeError, "Cannot accept NaN weights.");
+        return NULL;
+      }
     }
 
     if (nb_partitions == 0)
@@ -184,7 +188,8 @@ extern "C"
       size_t nb_is_membership_fixed = PyList_Size(py_is_membership_fixed);
       if (nb_is_membership_fixed != n)
       {
-        throw Exception("Node size vector not the same size as the number of nodes.");
+        PyErr_SetString(PyExc_TypeError, "Node size vector not the same size as the number of nodes.");
+        return NULL;
       }
 
       for (size_t v = 0; v < n; v++)
@@ -265,7 +270,8 @@ extern "C"
       size_t nb_is_membership_fixed = PyList_Size(py_is_membership_fixed);
       if (nb_is_membership_fixed != n)
       {
-        throw Exception("Node size vector not the same size as the number of nodes.");
+        PyErr_SetString(PyExc_TypeError, "Node size vector not the same size as the number of nodes.");
+        return NULL;
       }
 
       for (size_t v = 0; v < n; v++)
@@ -340,7 +346,8 @@ extern "C"
       size_t nb_is_membership_fixed = PyList_Size(py_is_membership_fixed);
       if (nb_is_membership_fixed != n)
       {
-        throw Exception("Node size vector not the same size as the number of nodes.");
+        PyErr_SetString(PyExc_TypeError, "Node size vector not the same size as the number of nodes.");
+        return NULL;
       }
 
       for (size_t v = 0; v < n; v++)



View it on GitLab: https://salsa.debian.org/med-team/python-leidenalg/-/commit/eefd31db4aab24dec4d2bfb0851fd2efd07b4d27

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-leidenalg/-/commit/eefd31db4aab24dec4d2bfb0851fd2efd07b4d27
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20211019/9606441d/attachment-0001.htm>


More information about the debian-med-commit mailing list