Differences between linux and os x (possibly numpy related?)
I have found an inconsistent behaviour with graph_tool version 2.43 on two different systems. In both cases I have installed via conda-forge. On the linux system I have
import graph_tool.all as gt
gt.__version__
'2.43 (commit 5778eb10, )'
for python 3.8, numpy 1.21.2
On os x I have
import graph_tool.all as gt
gt.__version__
'2.43 (commit , )'
for python 3.8 and numpy 1.21.2 again.
I have tried a simple code (following #713 ) which is returning two different errors on both systems. On OSX I have
g = gt.collection.ns["new_guinea_tribes"]
state = gt.minimize_nested_blockmodel_dl(g,
state_args=dict(base_type=gt.LayeredBlockState,
state_args=dict(ec=g.ep.weight, layers=True)))
missing = [(0, 6, 1), (0, 6, -1)]
state.get_edges_prob(missing)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-fadd85695711> in <module>
5
6 missing = [(0, 6, 1), (0, 6, -1)]
----> 7 state.get_edges_prob(missing)
~/anaconda3/envs/experimental/lib/python3.8/site-packages/graph_tool/inference/nested_blockmodel.py in get_edges_prob(self, missing, spurious, entropy_args)
441 lstate._state.clear_egroups()
442
--> 443 L += lstate.get_edges_prob(missing, spurious, entropy_args=eargs)
444 if isinstance(self.levels[0], LayeredBlockState):
445 missing = [(lstate.b[u], lstate.b[v], l_) for u, v, l_ in missing]
~/anaconda3/envs/experimental/lib/python3.8/site-packages/graph_tool/inference/layered_blockmodel.py in get_edges_prob(self, missing, spurious, entropy_args)
788
789 nes.append((u, v, (l, False)))
--> 790 nes.append((self._get_lvertex(u, l),
791 self._get_lvertex(v, l), (l, True)))
792
~/anaconda3/envs/experimental/lib/python3.8/site-packages/graph_tool/inference/layered_blockmodel.py in _get_lvertex(self, v, l)
748 def _get_lvertex(self, v, l):
749 i = numpy.searchsorted(self.vc[v].a, l)
--> 750 if i >= len(self.vc[v]) or l != self.vc[v][i]:
751 raise ValueError("vertex %d not present in layer %d" % (v, l))
752 u = self.vmap[v][i]
TypeError: Invalid index type
whereas on linux I have
g = gt.collection.ns["new_guinea_tribes"]
state = gt.minimize_nested_blockmodel_dl(g,
state_args=dict(base_type=gt.LayeredBlockState,
state_args=dict(ec=g.ep.weight, layers=True)))
missing = [(0, 6, 1), (0, 6, -1)]
state.get_edges_prob(missing)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/beegfs/scratch/tmp/ipykernel_16854/740866967.py in <module>
5
6 missing = [(0, 6, 1), (0, 6, -1)]
----> 7 state.get_edges_prob(missing)
~/miniforge3/envs/singlecell/lib/python3.8/site-packages/graph_tool/inference/nested_blockmodel.py in get_edges_prob(self, missing, spurious, entropy_args)
441 lstate._state.clear_egroups()
442
--> 443 L += lstate.get_edges_prob(missing, spurious, entropy_args=eargs)
444 if isinstance(self.levels[0], LayeredBlockState):
445 missing = [(lstate.b[u], lstate.b[v], l_) for u, v, l_ in missing]
~/miniforge3/envs/singlecell/lib/python3.8/site-packages/graph_tool/inference/layered_blockmodel.py in get_edges_prob(self, missing, spurious, entropy_args)
789 nes.append((u, v, (l, False)))
790 nes.append((self._get_lvertex(u, l),
--> 791 self._get_lvertex(v, l), (l, True)))
792
793 edge_list = nes
~/miniforge3/envs/singlecell/lib/python3.8/site-packages/graph_tool/inference/layered_blockmodel.py in _get_lvertex(self, v, l)
749 i = numpy.searchsorted(self.vc[v].a, l)
750 if i >= len(self.vc[v]) or l != self.vc[v][i]:
--> 751 raise ValueError("vertex %d not present in layer %d" % (v, l))
752 u = self.vmap[v][i]
753 return u
ValueError: vertex 6 not present in layer 1
which is the correct behaviour (at least for the intent of this bug report).