GuyAllard / markov_clustering

markov clustering in python
MIT License
168 stars 37 forks source link

markov_clustering not works with scipy 1.3.0 #17

Open ggautreau opened 5 years ago

ggautreau commented 5 years ago

I just copied the README example in a python console:

Python 3.7.3 (default, Mar 27 2019, 22:11:17) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import markov_clustering as mc
Matplotlib not present
Visualization not supported to missing libraries.
>>> import networkx as nx
>>> import random
>>> 
>>> # number of nodes to use
... numnodes = 200
>>> 
>>> # generate random positions as a dictionary where the key is the node id and the value
... # is a tuple containing 2D coordinates
... positions = {i:(random.random() * 2 - 1, random.random() * 2 - 1) for i in range(numnodes)}
>>> 
>>> network = nx.random_geometric_graph(numnodes, 0.3, pos=positions)
>>> 
>>> # then get the adjacency matrix (in sparse form)
... matrix = nx.to_scipy_sparse_matrix(network)
>>> result = mc.run_mcl(matrix)           # run MCL with default parameters
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/env/export/cns_n02_scratch/scratch_agc/scratch/agc/users/ggautrea/miniconda3/lib/python3.7/site-packages/markov_clustering-0.0.6.dev0-py3.7.egg/markov_clustering/mcl.py", line 233, in run_mcl
    matrix = prune(matrix, pruning_threshold)
  File "/env/export/cns_n02_scratch/scratch_agc/scratch/agc/users/ggautrea/miniconda3/lib/python3.7/site-packages/markov_clustering-0.0.6.dev0-py3.7.egg/markov_clustering/mcl.py", line 93, in prune
    pruned[matrix >= threshold] = matrix[matrix >= threshold]
  File "/env/export/cns_n02_scratch/scratch_agc/scratch/agc/users/ggautrea/miniconda3/lib/python3.7/site-packages/scipy/sparse/_index.py", line 109, in __setitem__
    raise ValueError("shape mismatch in assignment")
ValueError: shape mismatch in assignment
>>> clusters = mc.get_clusters(result)    # get clusters
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'result' is not defined
>>> import scipy
>>> scipy.__version__
'1.3.0'

But if instead of the scipy 1.3.0 version i use the scipy 1.2.0 one, it works fine.

KeironO commented 5 years ago

Can confirm that it no longer works with scipy 1.3.0.

I will look into fixing this tonight, and submit a pull request once tested

duboism commented 3 years ago

I just tested the example with scipy 1.5.4 and it seems to work.