Commit 136db0e2 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

blockmodel.py: Fix bug with ignore_degrees

parent d9bcc66f
Pipeline #138 passed with stage
......@@ -56,7 +56,7 @@ typedef mpl::vector2<simple_degs_t, degs_map_t> degs_tr;
((pclabel,, vmap_t, 0)) \
((merge_map,, vmap_t, 0)) \
((deg_corr,, bool, 0)) \
((ignore_degree,, typename vprop_map_t<uint8_t>::type, 0))
((ignore_degrees,, typename vprop_map_t<uint8_t>::type, 0))
GEN_STATE_BASE(BlockStateBase, BLOCK_STATE_params)
......@@ -804,11 +804,11 @@ public:
double get_deg_entropy(size_t v, const simple_degs_t&)
{
if (_ignore_degree[v] == 1)
if (_ignore_degrees[v] == 1)
return 0;
auto kin = in_degreeS()(v, _g);
auto kout = out_degreeS()(v, _g);
if (_ignore_degree[v] == 2)
if (_ignore_degrees[v] == 2)
kout = 0;
double S = -lgamma_fast(kin + 1) - lgamma_fast(kout + 1);
return S * _vweight[v];
......@@ -816,14 +816,14 @@ public:
double get_deg_entropy(size_t v, typename degs_map_t::unchecked_t& degs)
{
if (_ignore_degree[v] == 1)
if (_ignore_degrees[v] == 1)
return 0;
double S = 0;
for (auto& ks : degs[v])
{
auto kin = get<0>(ks);
auto kout = get<1>(ks);
if (_ignore_degree[v] == 2)
if (_ignore_degrees[v] == 2)
kout = 0;
int n = get<2>(ks);
S -= n * (lgamma_fast(kin + 1) + lgamma_fast(kout + 1));
......@@ -991,7 +991,7 @@ public:
for (size_t c = 0; c < C; ++c)
_partition_stats.emplace_back(_g, _b, vcs[c], E, B,
_vweight, _eweight, _degs,
_ignore_degree, _bmap);
_ignore_degrees, _bmap);
for (auto r : vertices_range(_bg))
_partition_stats[rc[r]].get_r(r);
......
......@@ -353,9 +353,18 @@ public:
r = get_r(r);
nr = get_r(nr);
auto&& ks = get_degs(v, vweight, eweight, degs, g);
auto* _ks = &ks;
typename std::remove_reference<decltype(ks)>::type nks;
if (_ignore_degree[v] == 2)
{
nks = ks;
for (auto& k : nks)
get<1>(k) = 0;
_ks = &nks;
}
double dS = 0;
dS += get_delta_deg_dl_change(v, r, ks, -1);
dS += get_delta_deg_dl_change(v, nr, ks, +1);
dS += get_delta_deg_dl_change(v, r, *_ks, -1);
dS += get_delta_deg_dl_change(v, nr, *_ks, +1);
return dS;
}
......
......@@ -215,8 +215,6 @@ class BlockState(object):
self.merge_map = kwargs.get("merge_map", self.g.vertex_index.copy("int"))
self.ignore_degree = kwargs.get("ignore_degree",
self.g.new_vp("bool", False))
self.block_list = Vector_size_t()
self.block_list.extend(arange(self.B, dtype="int"))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment