Repository: scverse/scanpy

Issue:
pyproject.toml should refer to `igraph` and not `python-igraph`
### Please make sure these conditions are met

- [X] I have checked that this issue has not already been reported.
- [X] I have confirmed this bug exists on the latest version of scanpy.
- [X] (optional) I have confirmed this bug exists on the master branch of scanpy.

### What happened?

I've noticed that `pyproject.toml` refers to the `python-igraph` package in the PyPI repository. This name is deprecated; the `igraph` package is currently called [`igraph`](https://pypi.org/project/igraph). The old package name currently works as a redirect (i.e. it brings in `igraph` as its own sub-dependency), but it will not be maintained in the future. Please switch to referring to `igraph` in `pyproject.toml` and not `python-igraph`.

### Minimal code sample

```python
N/A
```


### Error output

_No response_

### Versions

<details>

```
-----
anndata     0.9.1
scanpy      1.9.3
-----
PIL                 10.0.0
cycler              0.10.0
cython_runtime      NA
dateutil            2.8.2
h5py                3.9.0
joblib              1.3.1
kiwisolver          1.4.4
llvmlite            0.40.1
matplotlib          3.7.2
mpl_toolkits        NA
natsort             8.4.0
numba               0.57.1
numpy               1.24.4
packaging           23.1
pandas              2.0.3
pyparsing           3.0.9
pytz                2023.3
scipy               1.11.1
session_info        1.0.0
sitecustomize       NA
six                 1.16.0
sklearn             1.3.0
threadpoolctl       3.2.0
-----
Python 3.11.4 (main, Jun 20 2023, 17:23:00) [Clang 14.0.3 (clang-1403.0.22.14.1)]
macOS-13.2.1-arm64-arm-64bit
-----
Session information updated at 2023-07-19 13:34
```

</details>

BaseException: Could not construct partition: Weight vector not the same size as the number of edges.
- [X] I have checked that this issue has not already been reported.
- [X] I have confirmed this bug exists on the latest version of scanpy.
- [ ] (optional) I have confirmed this bug exists on the master branch of scanpy.

---
I have been trying to replicate [this tutorial](https://scanpy-tutorials.readthedocs.io/en/latest/paga-paul15.html#Clustering-and-PAGA) on trajectory inference. I have followed every step up until clustering, where I try to use sc.tl.leiden(adata) to cluster, but keep having the following error. This seemed to have resolved itself by installing leidenalg via pip, but with conda install it fails every time. 

### Minimal code sample (that we can copy&paste without having any data)

```python
sc.tl.leiden(adata)
```

```pytb
BaseException Traceback (most recent call last)
Cell In [15], line 1
----> 1 sc.tl.leiden(adata)

File ~/miniconda3/envs/py39/lib/python3.9/site-packages/scanpy/tools/_leiden.py:144, in leiden(adata, resolution, restrict_to, random_state, key_added, adjacency, directed, use_weights, n_iterations, partition_type, neighbors_key, obsp, copy, **partition_kwargs)
142 partition_kwargs[‘resolution_parameter’] = resolution
143 # clustering proper
→ 144 part = leidenalg.find_partition(g, partition_type, **partition_kwargs)
145 # store output into adata.obs
146 groups = np.array(part.membership)

File ~/miniconda3/envs/py39/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 ~/miniconda3/envs/py39/lib/python3.9/site-packages/leidenalg/VertexPartition.py:855, in RBConfigurationVertexPartition.init(self, graph, initial_membership, weights, node_sizes, resolution_parameter)
851 else:
852 # Make sure it is a list
853 node_sizes = list(node_sizes)
→ 855 self._partition = _c_leiden._new_RBConfigurationVertexPartition(pygraph_t,
856 initial_membership, weights, node_sizes, resolution_parameter)
857 self._update_internal_membership()

BaseException: Could not construct partition: Weight vector not the same size as the number of edges.
```

#### Versions

<details>

```
anndata     0.8.0
scanpy      1.9.1
-----
PIL                 9.2.0
appnope             0.1.3
asttokens           NA
backcall            0.2.0
beta_ufunc          NA
binom_ufunc         NA
cffi                1.15.1
colorama            0.4.5
cycler              0.10.0
cython_runtime      NA
dateutil            2.8.2
debugpy             1.6.3
decorator           5.1.1
defusedxml          0.7.1
entrypoints         0.4
executing           1.1.0
h5py                3.7.0
hypergeom_ufunc     NA
igraph              0.9.11
ipykernel           6.16.0
ipython_genutils    0.2.0
ipywidgets          8.0.2
jedi                0.18.1
joblib              1.2.0
jupyter_server      1.19.1
kiwisolver          1.4.4
leidenalg           0.8.10
llvmlite            0.39.1
louvain             0.7.1
matplotlib          3.6.0
matplotlib_inline   0.1.6
mpl_toolkits        NA
natsort             8.2.0
nbinom_ufunc        NA
ncf_ufunc           NA
numba               0.56.2
numpy               1.23.3
packaging           21.3
pandas              1.5.0
parso               0.8.3
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
prompt_toolkit      3.0.31
psutil              5.9.2
ptyprocess          0.7.0
pure_eval           0.2.2
pycparser           2.21
pydev_ipython       NA
pydevconsole        NA
pydevd              2.8.0
pydevd_file_utils   NA
pydevd_plugins      NA
pydevd_tracing      NA
pygments            2.13.0
pynndescent         0.5.7
pyparsing           3.0.9
pytz                2022.2.1
scipy               1.9.1
session_info        1.0.0
setuptools          65.4.0
six                 1.16.0
sklearn             1.1.2
sphinxcontrib       NA
stack_data          0.5.1
statsmodels         0.13.2
texttable           1.6.4
threadpoolctl       3.1.0
tornado             6.2
tqdm                4.64.1
traitlets           5.4.0
typing_extensions   NA
umap                0.5.3
wcwidth             0.2.5
zipp                NA
zmq                 24.0.1
zoneinfo            NA
-----
IPython             8.5.0
jupyter_client      7.3.5
jupyter_core        4.11.1
jupyterlab          3.4.7
notebook            6.4.12
-----
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 17:00:33) [Clang 13.0.1 ]
macOS-12.6-arm64-arm-64bit
-----
Session information updated at 2022-09-29 11:08
```

</details>



Discussion:

I installed leidenalg through conda today and encountered the same error.
This is identical with #2339

The simplest way is to downgrade `python-igraph` to `0.9.9`, https://github.com/scverse/scanpy/issues/2339#issuecomment-1261132252
I tried this with igraph 0.10.1 and leidenalg 0.9.0 and everything appears to work correctly.

Note that leidenalg 0.9.x requires igraph 0.10.x and leidenalg 0.8.x requires igraph 0.9.x. I believe this is the problem that comment refers to, @hansen7.
I am still facing the same issue, tries using leidenalg==0.8 and python-igraph==0.9.9 ,
Any suggestions would be of great help.
#2339
ys-zong/conST#3 was the only versions that worked for me, no solution from the above worked.
Also running into this now with pertpy. 

```
-----
anndata     0.9.1
scanpy      1.9.3
-----
PIL                 10.0.0
cffi                1.15.1
colorama            0.4.6
cycler              0.10.0
cython_runtime      NA
dateutil            2.8.2
defusedxml          0.7.1
h5py                3.9.0
igraph              0.9.7
joblib              1.3.1
kiwisolver          1.4.4
leidenalg           0.10.0
llvmlite            0.40.1
matplotlib          3.7.2
mpl_toolkits        NA
mpmath              1.3.0
natsort             8.4.0
numba               0.57.1
numpy               1.24.4
nvfuser             NA
opt_einsum          v3.3.0
packaging           23.1
pandas              2.0.3
psutil              5.9.5
pyarrow             12.0.1
pyparsing           3.0.9
pytz                2023.3
scipy               1.11.1
session_info        1.0.0
six                 1.16.0
sklearn             1.3.0
sphinxcontrib       NA
sympy               1.12
texttable           1.6.7
threadpoolctl       3.2.0
torch               2.0.1+cu117
tqdm                4.65.0
typing_extensions   NA
wcwidth             0.2.6
yaml                6.0.1
-----
Python 3.10.9 (main, Jan 11 2023, 15:21:40) [GCC 11.2.0]
Linux-6.4.3-arch1-2-x86_64-with-glibc2.37
-----
Session information updated at 2023-07-19 12:57
```
@Zethson See my comment above. You have a version mismatch between igraph and leidenalg. Use the latest of both.
> @Zethson See my comment above. You have a version mismatch between igraph and leidenalg. Use the latest of both.

I know. The issue is that `poetry update` defaults to this combination in my environment for pertpy. I'll probably have to set minimum requirements.

Thanks nevertheless!

Resolving patch:
diff --git a/scanpy/logging.py b/scanpy/logging.py
--- a/scanpy/logging.py
+++ b/scanpy/logging.py
@@ -127,7 +127,7 @@ def format(self, record: logging.LogRecord):
     'pandas',
     ('sklearn', 'scikit-learn'),
     'statsmodels',
-    ('igraph', 'python-igraph'),
+    'igraph',
     'louvain',
     'leidenalg',
     'pynndescent',


Test patch:
diff --git a/scanpy/testing/_pytest/marks.py b/scanpy/testing/_pytest/marks.py
--- a/scanpy/testing/_pytest/marks.py
+++ b/scanpy/testing/_pytest/marks.py
@@ -10,7 +10,7 @@
     louvain="louvain",
     skmisc="scikit-misc",
     fa2="fa2",
-    igraph="python-igraph",
+    igraph="igraph",
     dask="dask",
     zarr="zarr",
     zappy="zappy",