GGiecold-zz / Cluster_Ensembles

A package for combining multiple partitions into a consolidated clustering. The combinatorial optimization problem of obtaining such a consensus clustering is reformulated in terms of approximation algorithms for graph or hyper-graph partitioning.
MIT License
69 stars 43 forks source link

Move to Python 3 #16

Closed connorjoleary closed 4 years ago

connorjoleary commented 5 years ago

Allow this code to be used in python 3.5 as well as python 2.7.

Currently when run, I receive


    294         function_names = ['CSPA', 'HGPA', 'MCLA']
    295 
--> 296     hypergraph_adjacency = build_hypergraph_adjacency(cluster_runs)
    297     store_hypergraph_adjacency(hypergraph_adjacency, hdf5_file_name)
    298 

~/venv/mlClass/lib/python3.5/site-packages/Cluster_Ensembles/Cluster_Ensembles.py in build_hypergraph_adjacency(cluster_runs)
    166     N_runs = cluster_runs.shape[0]
    167 
--> 168     hypergraph_adjacency = create_membership_matrix(cluster_runs[0])
    169     for i in xrange(1, N_runs):
    170         hypergraph_adjacency = scipy.sparse.vstack([hypergraph_adjacency,

~/venv/mlClass/lib/python3.5/site-packages/Cluster_Ensembles/Cluster_Ensembles.py in create_membership_matrix(cluster_run)
    890     cluster_run = np.asanyarray(cluster_run)
    891 
--> 892     if reduce(operator.mul, cluster_run.shape, 1) != max(cluster_run.shape):
    893         raise ValueError("\nERROR: Cluster_Ensembles: create_membership_matrix: "
    894                          "problem in dimensions of the cluster label vector "

NameError: name 'reduce' is not defined```
hashlash commented 3 years ago

@GGiecold Is there any particular reason for not moving to python 3? Python 2 has reached its end of life https://www.python.org/doc/sunset-python-2/