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
53933d87
Commit
53933d87
authored
Apr 02, 2016
by
Tiago Peixoto
Browse files
Fix test_inference.py
parent
62a57e77
Pipeline
#128
failed with stage
Changes
2
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
doc/inference.rst
View file @
53933d87
This diff is collapsed.
Click to expand it.
doc/test_inference.py
View file @
53933d87
#!/bin/env python
verbose
=
False
import
os
import
sys
if
not
verbose
:
f
=
open
(
os
.
devnull
,
'w'
)
sys
.
stdout
=
f
from
graph_tool.all
import
*
import
numpy.random
from
numpy.random
import
randint
...
...
@@ -36,10 +44,11 @@ for directed in [True, False]:
for
dl
in
[
False
,
True
]:
print
(
"
\n
directed:"
,
directed
,
"overlap:"
,
overlap
,
"layered:"
,
layered
,
"deg-corr:"
,
deg_corr
,
"dl:"
,
dl
)
"layered:"
,
layered
,
"deg-corr:"
,
deg_corr
,
"dl:"
,
dl
,
file
=
sys
.
stdout
)
print
(
"
\t
mcmc (unweighted)"
)
print
(
"
\t
mcmc (unweighted)"
,
file
=
sys
.
stdout
)
state
=
gen_state
(
directed
,
deg_corr
,
layered
,
overlap
)
print
(
"
\t\t
"
,
state
.
mcmc_sweep
(
beta
=
0
,
allow_empty
=
True
,
...
...
@@ -49,12 +58,13 @@ for directed in [True, False]:
print
(
"
\t\t
"
,
state
.
mcmc_sweep
(
beta
=
0
,
bundled
=
True
,
allow_empty
=
True
,
entropy_args
=
dict
(
dl
=
dl
)),
(
state
.
wr
.
a
>
0
).
sum
())
(
state
.
wr
.
a
>
0
).
sum
(),
file
=
sys
.
stdout
)
state
=
gen_state
(
directed
,
deg_corr
,
layered
,
overlap
)
if
not
overlap
:
print
(
"
\t
mcmc"
)
print
(
"
\t
mcmc"
,
file
=
sys
.
stdout
)
bstate
=
state
.
get_block_state
(
vweight
=
True
,
deg_corr
=
deg_corr
)
...
...
@@ -63,7 +73,7 @@ for directed in [True, False]:
allow_empty
=
True
,
entropy_args
=
dict
(
dl
=
dl
,
multigraph
=
False
)),
(
bstate
.
wr
.
a
>
0
).
sum
())
(
bstate
.
wr
.
a
>
0
).
sum
()
,
file
=
sys
.
stdout
)
print
(
"
\t\t
"
,
bstate
.
mcmc_sweep
(
beta
=
0
,
allow_empty
=
True
,
...
...
@@ -75,9 +85,9 @@ for directed in [True, False]:
bstate
.
gibbs_sweep
(
beta
=
0
,
allow_empty
=
True
,
entropy_args
=
dict
(
dl
=
dl
,
multigraph
=
False
)),
(
bstate
.
wr
.
a
>
0
).
sum
())
(
bstate
.
wr
.
a
>
0
).
sum
()
,
file
=
sys
.
stdout
)
print
(
"
\t
merge"
)
print
(
"
\t
merge"
,
file
=
sys
.
stdout
)
state
=
gen_state
(
directed
,
deg_corr
,
layered
,
overlap
)
...
...
@@ -88,30 +98,34 @@ for directed in [True, False]:
print
(
"
\t\t
"
,
bstate
.
merge_sweep
(
50
,
entropy_args
=
dict
(
dl
=
dl
,
multigraph
=
False
)))
multigraph
=
False
)),
file
=
sys
.
stdout
)
bstate
=
bstate
.
copy
()
print
(
"
\t\t
"
,
bstate
.
mcmc_sweep
(
beta
=
0
,
allow_empty
=
True
,
entropy_args
=
dict
(
dl
=
dl
,
multigraph
=
False
)))
multigraph
=
False
)),
file
=
sys
.
stdout
)
print
(
"
\t\t
"
,
bstate
.
gibbs_sweep
(
beta
=
0
,
allow_empty
=
True
,
entropy_args
=
dict
(
dl
=
dl
,
multigraph
=
False
)))
multigraph
=
False
)),
file
=
sys
.
stdout
)
else
:
print
(
"
\t\t
"
,
state
.
merge_sweep
(
50
,
entropy_args
=
dict
(
dl
=
dl
,
multigraph
=
False
)))
multigraph
=
False
)),
file
=
sys
.
stdout
)
print
(
"
\t
shrink"
)
print
(
"
\t
shrink"
,
file
=
sys
.
stdout
)
state
=
gen_state
(
directed
,
deg_corr
,
layered
,
overlap
)
state
=
state
.
shrink
(
B
=
5
,
entropy_args
=
dict
(
dl
=
dl
,
multigraph
=
False
))
print
(
"
\t\t
"
,
state
.
B
)
print
(
"
\t\t
"
,
state
.
B
,
file
=
sys
.
stdout
)
for
directed
in
[
True
,
False
]:
for
overlap
in
[
False
,
True
]:
...
...
@@ -121,21 +135,23 @@ for directed in [True, False]:
"layered:"
,
layered
,
"deg-corr:"
,
deg_corr
)
state
=
minimize_blockmodel_dl
(
GraphView
(
g
,
directed
=
directed
),
verbose
=
(
1
,
"
\t
"
),
verbose
=
(
1
,
"
\t
"
)
if
verbose
else
False
,
deg_corr
=
deg_corr
,
overlap
=
overlap
,
layers
=
layered
!=
False
,
state_args
=
dict
(
ec
=
ec
,
layers
=
(
layered
==
True
)))
print
(
state
.
B
,
state
.
entropy
())
print
(
state
.
B
,
state
.
entropy
()
,
file
=
sys
.
stdout
)
state
=
minimize_nested_blockmodel_dl
(
GraphView
(
g
,
directed
=
directed
),
verbose
=
(
1
,
"
\t
"
),
verbose
=
(
1
,
"
\t
"
)
if
verbose
else
False
,
deg_corr
=
deg_corr
,
overlap
=
overlap
,
layers
=
layered
!=
False
,
state_args
=
dict
(
ec
=
ec
,
layers
=
(
layered
==
True
)))
state
.
print_summary
()
print
(
state
.
entropy
())
if
verbose
:
state
.
print_summary
()
print
(
state
.
entropy
(),
file
=
sys
.
stdout
)
print
(
"OK"
)
\ No newline at end of file
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