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
162b8c06
Commit
162b8c06
authored
May 01, 2020
by
Tiago Peixoto
Browse files
uncertain_blockmodel: fix state copying
parent
7008f4ff
Changes
1
Show whitespace changes
Inline
Side-by-side
src/graph_tool/inference/uncertain_blockmodel.py
View file @
162b8c06
...
...
@@ -58,11 +58,19 @@ class UncertainBaseState(object):
self
.
u
=
g
.
copy
()
self
.
eweight
=
self
.
u
.
new_ep
(
"int"
,
val
=
1
)
else
:
self
.
u
=
bstate
.
g
self
.
u
=
bstate
.
g
.
copy
()
if
nested
:
self
.
eweight
=
bstate
.
levels
[
0
].
eweight
else
:
self
.
eweight
=
bstate
.
eweight
self
.
eweight
=
self
.
u
.
own_property
(
self
.
eweight
.
copy
())
if
nested
:
bstate
=
bstate
.
copy
(
g
=
self
.
u
,
state_args
=
dict
(
bstate
.
state_args
,
eweight
=
self
.
eweight
))
else
:
bstate
=
bstate
.
copy
(
g
=
self
.
u
,
eweight
=
self
.
eweight
)
self
.
u
.
set_fast_edge_removal
()
self
.
self_loops
=
self_loops
...
...
@@ -84,9 +92,7 @@ class UncertainBaseState(object):
if
nested
:
state_args
[
"state_args"
]
=
state_args
.
get
(
"state_args"
,
{})
state_args
[
"state_args"
][
"eweight"
]
=
self
.
eweight
state_args
[
"sampling"
]
=
True
self
.
nbstate
=
NestedBlockState
(
self
.
u
,
**
dict
(
state_args
,
sampling
=
True
))
self
.
nbstate
=
NestedBlockState
(
self
.
u
,
state_args
)
self
.
bstate
=
self
.
nbstate
.
levels
[
0
]
else
:
self
.
nbstate
=
None
...
...
@@ -110,15 +116,8 @@ class UncertainBaseState(object):
init_q_cache
()
def
__getstate__
(
self
):
self
.
u
.
ep
.
w
=
self
.
eweight
u
=
self
.
u
.
copy
()
eweight
=
u
.
ep
.
w
del
u
.
ep
[
"w"
]
del
self
.
u
.
ep
[
"w"
]
return
dict
(
g
=
self
.
g
,
nested
=
self
.
nbstate
is
not
None
,
bstate
=
(
self
.
nbstate
.
copy
(
g
=
u
,
state_args
=
dict
(
eweight
=
eweight
))
if
self
.
nbstate
is
not
None
else
self
.
bstate
.
copy
(
g
=
u
,
eweight
=
eweight
)),
bstate
=
(
self
.
nbstate
if
self
.
nbstate
is
not
None
else
self
.
bstate
),
self_loops
=
self
.
self_loops
)
def
__setstate__
(
self
,
state
):
...
...
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