numpy int64 cannot be used for indexing VertexSeq

Bug #1168270 reported by Subhasis Ray
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
igraph
Fix Committed
Medium
Tamás Nepusz

Bug Description

Though there is no reference to numpy in the igraph docs, it is common to use numpy with python-igraph. The integer type returned by many numpy functions on 64 bit systems is numpy.int64. When such numbers are used for indexing a VertexSeq in igraph, the error:
KeyError: 'Attribute does not exist'

appears. This causes hard-to-track bugs in the python script. Common use case is,

g = igraph.Graph()
# Add some vertices and edges to g
sp = g.shortest_paths()
# Now we want to find paths shorter than some cutoff
sources, targets = numpy.nonzero(numpy.array(sp) < cutoff)
# Now we want to print some attributes of those vertices
for source_index, target_index in zip(sources, targets):
    print g.vs[source_index]['name'], g.vs[targte_index]['name']

Tamás Nepusz (ntamas)
Changed in igraph:
importance: Undecided → Medium
assignee: nobody → Tamás Nepusz (ntamas)
status: New → Confirmed
milestone: none → 0.7
Revision history for this message
Tamás Nepusz (ntamas) wrote :
Changed in igraph:
status: Confirmed → Fix Committed
Revision history for this message
Gábor Csárdi (gabor.csardi) wrote : Continue on github

The development of igraph has moved to github, so please do not comment on this bug here. You are of course welcome to comment on github, here:
https://github.com/igraph/igraph/issues/258

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.