Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differences between linux and osx behaviour (but bug for all) #65

Closed
dawe opened this issue Sep 2, 2021 · 3 comments
Closed

Differences between linux and osx behaviour (but bug for all) #65

dawe opened this issue Sep 2, 2021 · 3 comments

Comments

@dawe
Copy link

dawe commented Sep 2, 2021

Hi all, I am experiencing some issues 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 (package version py38hdc7f20d_0). On os x I have

import graph_tool.all as gt
gt.__version__
'2.43 (commit , )'

for python 3.8 (package version py38haa49ee5_0).
Since I'm interested in edge prediction on LayeredBlockState I have tried a simple code which I also reported on graph-tool official issue tracker. The problem is that the same code 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

According to Tiago's comments here it may be an issue with a proper compilation of the library.
Of course I may recompile myself graph-tool on os x, but having a fully functional package would save me a lot of time.

@count0
Copy link
Contributor

count0 commented Sep 2, 2021

Hi @dawe, I believe you have misunderstood my comment in the graph-tool issue tracker. I did not mention any issue with "proper compilation" of the library, instead I meant simply that fixes introduced in the git repository will appear only in the next release (2.44) or if you compile from the git version directly.

In any case, what you are experiencing seems to be a behavior difference with numpy when in linux or macos. Please open an issue at the graph-tool website so we can take a look at this properly.

@count0 count0 closed this as completed Sep 2, 2021
@dawe
Copy link
Author

dawe commented Sep 2, 2021

I see, sorry.
Also, there's a part I did not understand (only one? LOL!): the commit you mentioned is preceding the one for version bump to 2.43, so I assume from version 2.43 on the function is working properly.
I believe this is the case as:

  • the original error I posted in the mailing list was raised by graph-tool 2.40 (which I updated only yesterday)
  • Version 2.43 raises an error of vertex missing in a layer but the method is definitely in place.

@count0
Copy link
Contributor

count0 commented Sep 2, 2021

Yes, my mistake... The fix should be in the current version already! The problem you are experiencing is a different one. I commented upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants