Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
graph-tool
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
40
Issues
40
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tiago Peixoto
graph-tool
Commits
b681cbc3
Commit
b681cbc3
authored
May 26, 2015
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement attribute access to PropertyDict
parent
b98a11db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
+19
-4
doc/quickstart.rst
doc/quickstart.rst
+7
-0
src/graph_tool/__init__.py
src/graph_tool/__init__.py
+12
-4
No files found.
doc/quickstart.rst
View file @
b681cbc3
...
...
@@ -449,6 +449,13 @@ dictionaries:
42
>>> del g.graph_properties["foo"] # the property map entry is deleted from the dictionary
For convenience, the internal property maps can also be accessed via
attributes:
.. doctest::
>>> vprop = g.new_vertex_properties("double")
>>> g.vp.foo = vprop # equivalent to g.vp["foo"] = vprop
.. _sec_graph_io:
...
...
src/graph_tool/__init__.py
View file @
b681cbc3
...
...
@@ -1135,6 +1135,8 @@ class PropertyDict(dict):
"""Wrapper for the dict of vertex, graph or edge properties, which sets the
value on the property map when changed in the dict.
For convenience, the dictionary entries are also available via attributes.
.. note::
The class is only an one-way proxy to the internally-kept properties. If
...
...
@@ -1145,10 +1147,10 @@ class PropertyDict(dict):
def
__init__
(
self
,
g
,
old
,
get_func
,
set_func
,
del_func
):
dict
.
__init__
(
self
)
dict
.
update
(
self
,
old
)
s
elf
.
g
=
g
s
elf
.
get_func
=
get_func
s
elf
.
set_func
=
set_func
s
elf
.
del_func
=
del_func
s
uper
(
PropertyDict
,
self
).
__setattr__
(
"g"
,
g
)
s
uper
(
PropertyDict
,
self
).
__setattr__
(
"get_func"
,
get_func
)
s
uper
(
PropertyDict
,
self
).
__setattr__
(
"set_func"
,
set_func
)
s
uper
(
PropertyDict
,
self
).
__setattr__
(
"del_func"
,
del_func
)
def
__getitem__
(
self
,
key
):
if
self
.
get_func
!=
None
:
...
...
@@ -1174,6 +1176,12 @@ class PropertyDict(dict):
self
.
del_func
(
self
.
g
,
k
)
dict
.
clear
(
self
)
def
__getattr__
(
self
,
attr
):
return
self
.
__getitem__
(
attr
)
def
__setattr__
(
self
,
attr
,
val
):
return
self
.
__setitem__
(
attr
,
val
)
################################################################################
# Graph class
# The main graph interface
...
...
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