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
9d542a89
Commit
9d542a89
authored
Jun 11, 2009
by
Tiago Peixoto
Browse files
Make tgt parameter of Graph.copy_property() optional
parent
c2d45e12
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/core.py
View file @
9d542a89
...
...
@@ -562,12 +562,19 @@ class Graph(object):
# property map copying
@
_handle_exceptions
@
_require
(
"src"
,
PropertyMap
)
@
_require
(
"tgt"
,
PropertyMap
)
def
copy_property
(
self
,
src
,
tgt
,
g
=
None
):
"""Copy contents of `src` property to `tgt` property. The optional
parameter g specifices the (identical) source graph to copy properties
from (defaults to self).
@
_require
(
"tgt"
,
(
PropertyMap
,
type
(
None
)))
def
copy_property
(
self
,
src
,
tgt
=
None
,
g
=
None
):
"""Copy contents of `src` property to `tgt` property. If `tgt` is None,
then a new property map of the same type is created, and returned. The
optional parameter g specifices the (identical) source graph to copy
properties from (defaults to self).
"""
if
tgt
==
None
:
tgt
=
self
.
new_property
(
src
.
key_type
(),
src
.
value_type
())
ret
=
tgt
else
:
ret
=
None
if
src
.
key_type
()
!=
tgt
.
key_type
():
raise
GraphError
(
"source and target properties must have the same"
+
" key type"
)
...
...
@@ -587,6 +594,7 @@ class Graph(object):
self
.
pop_filter
()
if
g
!=
self
:
g
.
pop_filter
()
return
ret
# degree property map
@
_handle_exceptions
...
...
Write
Preview
Markdown
is supported
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