[graph-tool] Error with get_edges_prob in layered sbm

Anatol Wegner anatolweg at gmail.com
Fri Jan 17 05:29:43 CET 2020


Hi,

I am getting the following error when using get_edges_prob() with 
layered SBMs. Minimal example:

import graph_tool.all as gt
import numpy as np
gr=gt.generate_sbm(b=np.array([0]*500+[1]*500),probs=np.array([[10000,200],[200,10000]]))
etype=gr.new_edge_property('int')
gr.ep.etype=etype
for e in gr.edges():
     gr.ep.etype[e]=np.random.choice([0,1,2,3])
state = gt.minimize_nested_blockmodel_dl(gr, 
deg_corr=True,layers=True,state_args=dict(ec=gr.ep.etype,layers=True),verbose=False)

state.get_edges_prob([[2,32,0],[3,4,2]],spurious=[])

---------------------------------------------------------------------------
UnboundLocalError                          Traceback (most recent call last)
<ipython-input-30-a1758ce2345d>  in<module>()
7      gr.ep.etype[e]=np.random.choice([0,1,2,3])
8  state=  gt.inference.minimize_nested_blockmodel_dl(gr,  deg_corr=True,layers=True,state_args=dict(ec=gr.ep.etype,layers=True),verbose=False)
----> 9state.get_edges_prob([[2,32,0],[3,4,2]],spurious=[])

/usr/lib/python2.7/dist-packages/graph_tool/inference/nested_blockmodel.py  inget_edges_prob(self, missing, spurious, entropy_args)
481                      lstate._state.clear_egroups()
482  
--> 483L+=  lstate.get_edges_prob(missing,  spurious,  entropy_args=eargs)
484              if  isinstance(self.levels[0],  LayeredBlockState):
485                  missing=  [(lstate.b[u],  lstate.b[v],  l_)  for  u,  v,  l_in  missing]

/usr/lib/python2.7/dist-packages/graph_tool/inference/layered_blockmodel.py  inget_edges_prob(self, missing, spurious, entropy_args)
934                      state=  self.layer_states[l[0]]
935                  state.g.remove_edge(e)
--> 936for  u,  v,  lin  old_es:
937                  if  not  l[1]:
938                      state=  self.agg_state

UnboundLocalError: local variable 'old_es' referenced before assignment


Regards,
Anatol

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.skewed.de/pipermail/graph-tool/attachments/20200117/06774cd7/attachment-0001.htm>


More information about the graph-tool mailing list