please override __setslice__
Bug #557286 reported by
Ximin Luo
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
igraph |
New
|
Undecided
|
Unassigned |
Bug Description
at the moment, vs.__setslice__ has no effect (i guess es. is the same), yet doesn't throw an exception:
$ python
Python 2.5.5 (r255:77872, Feb 2 2010, 00:25:36)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from igraph import Graph
>>> g = Graph(4)
>>> g.vs["id"] = ["zero", "one", "two", "three"]
>>> g.vs["id"][1:3]
['one', 'two']
>>> g.vs["id"][1:3] = ["one-new", "two-new"]
>>> g.vs["id"][1:3]
['one', 'two']
To post a comment you must log in.
g.vs["id"] returns a copy of the appropriate slice of the underlying data structure, not the data structure itself; on the above copy, you are merely modifying the copy. However, you can use the slicing operator on g.vs itself, which returns another VertexSeq object (restricted to the appropriate set of vertices), and you can call __setslice__ on that:
>>> g.vs[1:3]["id"]
['one', 'two']
>>> g.vs[1:3]["id"] = ["one-new", "two-new"]
>>> g.vs["id"]
['zero', 'one-new', 'two-new', 'three']