Python-numpy index out of bound " für die Achse null

Ich habe einen code geschrieben in Python die der folgenden ähnelt:

def adamic_adar_prediction(graph):
    adjacencyMatrix = graph.get_adjacency()
    AAMatrix = adamic_adar_score(graph)
    AAMatrix  = np.array(AAMatrix)
    i = (-AAMatrix ).argsort(axis=None, kind='mergesort')
    j = np.unravel_index(i, AAMatrix .shape)
    sortedList = np.vstack(j).T
    print(sortedList.size)

    print(sortedList[1658943])
    print(sortedList[1658945])

Während das Ergebnis für das erste drucken ist 3,316,888 ich die folgende Fehlermeldung für die Letzte print:

IndexError: index 1658944 is out of bounds for axis 0 with size 1658944

Irgendeine Idee warum dieser Fehler entsteht, für mein array?

  • Verwenden print(sortedList[1658943]) statt.
  • Könntest du den genauen code? Wie "ähnlich" ist dieser code?
InformationsquelleAutor ahajib | 2015-04-20
Schreibe einen Kommentar