-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leiden clustering algorithm crashes on scanpy graph #796
Comments
Ran into this issue as well, the That said, I did the following to get around it:
Then passed Basically, changing the max argument for the random number generator to the max signed Noticed a few other things on the way to this which may help the developers, first |
That's not a problem -- the igraph wheel is compiled to be compliant with Python's internal ABI3 spec from Python 3.9 upwards, so any Python version from 3.9 upwards should be able to use the same wheel.
The comment is parenthesized incorrectly; it should be
The problem is that ScanPy is replacing the RNG with a NumPy-based one, under the assumption that it behaves identically to Python's >>> from random import Random
>>> rng = Random()
>>> max(rng.randint(0, 1) for _ in range(1000))
1
>>> from numpy.random import RandomState
>>> rng = RandomState()
>>> max(rng.randint(0, 1) for _ in range(1000))
0 So, all in all, I think that a |
I think a temporary workaround that does not skew the randomness might be this, assuming that import numpy as np
class RandomState(np.random.RandomState):
def getrandbits(self, k: int) -> int:
return super().tomaxint() & ((1 << k) - 1)
def randint(self, lo: int, hi: int) -> int:
return super().randint(lo, hi + 1)
rs = RandomState(np.random.MT19937(np.random.SeedSequence(0))) A better solution would be to start supporting NumPy random generators directly in |
After reading the NumPy docs for |
Describe the bug
This is a cross-reference of an existing bug already filed with scanpy developers, scverse/scanpy#2969.
When I run scanpy on Windows 11 with the Leiden clustering algorithm, it freezes with the following error message:
The exception is raised by the C core function
GraphBase.community_leiden
but it is not clear to me whether the bug is actually in the C core, or rather scanpy or the Python igraph layer feeding incorrect arguments or parameters. I posted it here as I guessed that the igraph devs would be able to identify whether the bug is in igraph or whether scanpy is passing inappropriate arguments to the igraph core routine or layer.To reproduce
Install scanpy on Windows 11 and run the following.
Version information
Which version of
python-igraph
are you using and where did you obtain it?I am using version 0.11.6, it was installed via
pip install igraph
.I checked using a Windows docker image to make it as reproducible as possible.
These last five lines repeat in a loop until the user terminates the shell with Ctrl-C.
I notice that the igraph wheel downloaded with pip has "cp39" in the filename, which is surprising as this is Python 3.12.
The text was updated successfully, but these errors were encountered: