Skip to content

TypeError: object of type 'int' has no len() #1

@NewPhrexian

Description

@NewPhrexian

It seems that the function MCLA.MCLA(cluster_runs, verbose = False, N_clusters_max = None) doesn't go well

Traceback (most recent call last):
File "/home/q1.py", line 333, in
ensemble_learning_mcla('finialdata/332SCL90.csv', 'SCL90', 3)
File "/home/q1.py", line 286, in ensemble_learning_mcla
clst = MCLA.MCLA(clusters, num_cluster)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/MCLA/MCLA.py", line 330, in MCLA
(edgecuts, parts) = metis.part_graph(G, N_clusters_max)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/anaconda3/envs/sm0501/lib/python3.11/site-packages/pymetis/init.py", line 339, in part_graph
xadj, adjncy = _prepare_graph(adjacency, xadj, adjncy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/anaconda3/envs/sm0501/lib/python3.11/site-packages/pymetis/init.py", line 266, in _prepare_graph
for i in range(len(adjacency)):
^^^^^^^^^^^^^^
TypeError: object of type 'int' has no len()

My code is your demo:
clusters = np.array([[1, 1, 1, 2, 2, 2], [1, 1, 2, 2, 2, 2]]) # not a list, but a np.array
num_cluster = 2
clst = MCLA.MCLA(clusters, num_cluster)
print(clst)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions