Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
4843cf1a
Commit
4843cf1a
authored
Apr 01, 2016
by
Tiago Peixoto
Browse files
Make PropertyMap objects iterable
This fixes issue #286
parent
9fcc539d
Pipeline
#125
passed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/__init__.py
View file @
4843cf1a
...
...
@@ -561,6 +561,16 @@ class PropertyMap(object):
"'(%s, %s)', wanted types: (%s, %s)"
%
(
str
(
k
),
str
(
v
),
str
(
type
(
k
)),
str
(
type
(
v
)),
kt
,
vt
))
def
__iter__
(
self
):
g
=
self
.
__g
()
if
self
.
key_type
()
==
"g"
:
iters
=
[
g
]
elif
self
.
key_type
()
==
"v"
:
iters
=
g
.
vertices
()
else
:
iters
=
g
.
edges
()
for
x
in
iters
:
yield
self
[
x
]
def
__repr__
(
self
):
# provide some more useful information
...
...
@@ -898,11 +908,6 @@ class PropertyMap(object):
self
.
__map
.
resize
(
size
)
self
.
__map
.
shrink_to_fit
()
def
__call__
(
self
,
a
):
p
=
self
.
copy
()
p
.
fa
=
a
return
p
def
__getstate__
(
self
):
g
=
self
.
get_graph
()
if
g
is
None
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment