vtraag / leidenalg

Implementation of the Leiden algorithm for various quality functions to be used with igraph in Python.
GNU General Public License v3.0
575 stars 77 forks source link

Could not construct partition: vector #117

Closed AlduCor closed 1 year ago

AlduCor commented 1 year ago

Hi I've recently upgraded from python-igraph 0.9 to igraph 0.10 since python-igraph seems is superceded by igraph (see: https://pypi.org/project/python-igraph/). I'm on MacOS, using conda.

However, when I run the following my get an error:

import leidenalg
import igraph as ig
G = ig.Graph.Famous('Zachary')
leidenalg.find_partition(G, leidenalg.ModularityVertexPartition)

Error Trace

---------------------------------------------------------------------------
BaseException                             Traceback (most recent call last)
/...02_mm_graphs.ipynb Cell 16 in <cell line: 4>()
      2 import igraph as ig
      3 G = ig.Graph.Famous('Zachary')
----> 4 leidenalg.find_partition(G, leidenalg.ModularityVertexPartition)

File ~/miniforge3/envs/.../lib/python3.9/site-packages/leidenalg/functions.py:81, in find_partition(graph, partition_type, initial_membership, weights, n_iterations, max_comm_size, seed, **kwargs)
     79 if not weights is None:
     80   kwargs['weights'] = weights
---> 81 partition = partition_type(graph,
     82                            initial_membership=initial_membership,
     83                            **kwargs)
     84 optimiser = Optimiser()
     86 optimiser.max_comm_size = max_comm_size

File ~/miniforge3/envs/.../lib/python3.9/site-packages/leidenalg/VertexPartition.py:456, in ModularityVertexPartition.__init__(self, graph, initial_membership, weights)
    452   else:
    453     # Make sure it is a list
    454     weights = list(weights)
--> 456 self._partition = _c_leiden._new_ModularityVertexPartition(pygraph_t,
    457     initial_membership, weights)
    458 self._update_internal_membership()

BaseException: Could not construct partition: vector

My Conda env

> conda list
# packages in environment at /.venv:
#
# Name                    Version                   Build  Channel
anyio                     3.6.2              pyhd8ed1ab_0    conda-forge
appnope                   0.1.3              pyhd8ed1ab_0    conda-forge
argon2-cffi               21.3.0             pyhd8ed1ab_0    conda-forge
argon2-cffi-bindings      21.2.0           py39h02fc5c5_3    conda-forge
asttokens                 2.1.0              pyhd8ed1ab_0    conda-forge
attrs                     22.1.0             pyh71513ae_1    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
beautifulsoup4            4.11.1             pyha770c72_0    conda-forge
bleach                    5.0.1              pyhd8ed1ab_0    conda-forge
bzip2                     1.0.8                h3422bc3_4    conda-forge
ca-certificates           2022.9.24            h4653dfc_0    conda-forge
certifi                   2022.9.24                pypi_0    pypi
cffi                      1.15.1           py39h7e6b969_1    conda-forge
charset-normalizer        2.1.1                    pypi_0    pypi
contourpy                 1.0.6                    pypi_0    pypi
cycler                    0.11.0                   pypi_0    pypi
debugpy                   1.6.3            py39h23fbdae_1    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
executing                 1.2.0              pyhd8ed1ab_0    conda-forge
flit-core                 3.8.0              pyhd8ed1ab_0    conda-forge
fonttools                 4.38.0                   pypi_0    pypi
idna                      3.4                pyhd8ed1ab_0    conda-forge
igraph                    0.10.2                   pypi_0    pypi
importlib-metadata        5.0.0              pyha770c72_1    conda-forge
importlib_resources       5.10.0             pyhd8ed1ab_0    conda-forge
ipykernel                 6.17.0             pyh736e0ef_0    conda-forge
ipython                   8.6.0              pyhd1c38e8_1    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                8.0.2              pyhd8ed1ab_1    conda-forge
jedi                      0.18.1             pyhd8ed1ab_2    conda-forge
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
jsonschema                4.17.0             pyhd8ed1ab_0    conda-forge
jupyter                   1.0.0            py39h2804cbe_7    conda-forge
jupyter_client            7.4.4              pyhd8ed1ab_0    conda-forge
jupyter_console           6.4.4              pyhd8ed1ab_0    conda-forge
jupyter_core              4.11.2           py39h2804cbe_0    conda-forge
jupyter_server            1.21.0             pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.2.2              pyhd8ed1ab_0    conda-forge
jupyterlab_widgets        3.0.3              pyhd8ed1ab_0    conda-forge
kiwisolver                1.4.4                    pypi_0    pypi
leidenalg                 0.9.0                    pypi_0    pypi
libblas                   3.9.0           16_osxarm64_openblas    conda-forge
libcblas                  3.9.0           16_osxarm64_openblas    conda-forge
libcxx                    14.0.6               h2692d47_0    conda-forge
libffi                    3.4.2                h3422bc3_5    conda-forge
libgfortran               5.0.0           11_3_0_hd922786_25    conda-forge
libgfortran5              11.3.0              hdaf2cc0_25    conda-forge
liblapack                 3.9.0           16_osxarm64_openblas    conda-forge
libopenblas               0.3.21          openmp_hc731615_3    conda-forge
libsodium                 1.0.18               h27ca646_1    conda-forge
libsqlite                 3.39.4               h76d750c_0    conda-forge
libzlib                   1.2.13               h03a7124_4    conda-forge
llvm-openmp               14.0.4               hd125106_0    conda-forge
markupsafe                2.1.1            py39h02fc5c5_2    conda-forge
matplotlib                3.6.2                    pypi_0    pypi
matplotlib-inline         0.1.6              pyhd8ed1ab_0    conda-forge
mistune                   2.0.4              pyhd8ed1ab_0    conda-forge
nbclassic                 0.4.8              pyhd8ed1ab_0    conda-forge
nbclient                  0.7.0              pyhd8ed1ab_0    conda-forge
nbconvert                 7.2.3              pyhd8ed1ab_0    conda-forge
nbconvert-core            7.2.3              pyhd8ed1ab_0    conda-forge
nbconvert-pandoc          7.2.3              pyhd8ed1ab_0    conda-forge
nbformat                  5.7.0              pyhd8ed1ab_0    conda-forge
ncurses                   6.3                  h07bb92c_1    conda-forge
nest-asyncio              1.5.6              pyhd8ed1ab_0    conda-forge
networkx                  2.8.8                    pypi_0    pypi
notebook                  6.5.2              pyha770c72_1    conda-forge
notebook-shim             0.2.2              pyhd8ed1ab_0    conda-forge
numpy                     1.23.4           py39hefdcf20_1    conda-forge
openssl                   3.0.7                h03a7124_0    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pandas                    1.5.1            py39hde7b980_1    conda-forge
pandoc                    2.19.2               hce30654_1    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
parso                     0.8.3              pyhd8ed1ab_0    conda-forge
pexpect                   4.8.0              pyh1a96a4e_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    9.3.0                    pypi_0    pypi
pip                       22.3.1             pyhd8ed1ab_0    conda-forge
pkgutil-resolve-name      1.3.10             pyhd8ed1ab_0    conda-forge
prometheus_client         0.15.0             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.32             pyha770c72_0    conda-forge
prompt_toolkit            3.0.32               hd8ed1ab_0    conda-forge
psutil                    5.9.3            py39h02fc5c5_1    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
pycairo                   1.21.0                   pypi_0    pypi
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pygments                  2.13.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
pyrsistent                0.19.2           py39h02fc5c5_0    conda-forge
python                    3.9.13          h96fcbfb_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-dotenv             0.21.0                   pypi_0    pypi
python-fastjsonschema     2.16.2             pyhd8ed1ab_0    conda-forge
python_abi                3.9                      2_cp39    conda-forge
pytz                      2022.6             pyhd8ed1ab_0    conda-forge
pyzmq                     24.0.1           py39h0553236_1    conda-forge
readline                  8.1.2                h46ed386_0    conda-forge
requests                  2.28.1                   pypi_0    pypi
scipy                     1.9.3                    pypi_0    pypi
send2trash                1.8.0              pyhd8ed1ab_0    conda-forge
setuptools                65.5.1             pyhd8ed1ab_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sniffio                   1.3.0              pyhd8ed1ab_0    conda-forge
soupsieve                 2.3.2.post1        pyhd8ed1ab_0    conda-forge
sqlite                    3.39.4               h2229b38_0    conda-forge
stack_data                0.6.0              pyhd8ed1ab_0    conda-forge
terminado                 0.17.0             pyhd1c38e8_0    conda-forge
texttable                 1.6.4                    pypi_0    pypi
tinycss2                  1.2.1              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               he1e0b03_0    conda-forge
tornado                   6.2              py39h02fc5c5_1    conda-forge
tqdm                      4.64.1                   pypi_0    pypi
traitlets                 5.5.0              pyhd8ed1ab_0    conda-forge
trieregex                 1.0.0                    pypi_0    pypi
typing_extensions         4.4.0              pyha770c72_0    conda-forge
tzdata                    2022f                h191b570_0    conda-forge
ujson                     5.5.0                    pypi_0    pypi
urllib3                   1.26.12                  pypi_0    pypi
vadersentiment            3.3.2                    pypi_0    pypi
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
websocket-client          1.4.2              pyhd8ed1ab_0    conda-forge
wheel                     0.38.2             pyhd8ed1ab_0    conda-forge
widgetsnbextension        4.0.3              pyhd8ed1ab_0    conda-forge
xlrd                      2.0.1                    pypi_0    pypi
xlsxwriter                3.0.3                    pypi_0    pypi
xz                        5.2.6                h57fd34a_0    conda-forge
zeromq                    4.3.4                hbdafb3b_1    conda-forge
zipp                      3.10.0             pyhd8ed1ab_0    conda-forge
AlduCor commented 1 year ago

You can safely ignore me. For posterity, the version of leidenalg and igraph were not in sync, due to pebkac.