- Notifications
You must be signed in to change notification settings - Fork 262
Generate graph from scipy sparse matrix #359
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
Conversation
| Huh, CI fails in an interesting way and I wouldn't mind some advice. It has to do with inheritance (alas!). This PR currently has @classmethod def Adjacency(klass, ...): return GraphBase.Adjacency(...) # or return super().Adjacency(...)does not work, because I could make another copy of |
| I think that this is a bug in Edit: it seems like I have already started adding test cases for inheritance in |
| @iosonofabio It looks like the correct syntax for calling a class method of the superclass is: So I would try something like |
ntamas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor comments here and there, otherwise I think it's good to go!
| I fixed those, but let me add the weighted case too since I'm here |
b85be59 to 3d9a77c Compare 46a7f46 to d8b1e3f Compare | rebased on top of the GitHub actions PR, let's see if this works |
| @iosonofabio Can you rebase this once again on top of |
| Sorry for spoiling your PR discussion: It is just a pity this could not make it into the latest release. Would be a very useful feature! |
| There will be a 0.9.1 soon(ish) as the API documentation build is currently broken, so I'm hoping to squeeze this into that one. |
| Okay, I'm gonna merge this into |
This tries to implement #357, i.e. generating a
Graphobject from a sparse scipy matrix, which is the de facto standard in Pythonlands for such cases.The key is to bypass
GraphBase.Adjacency, which dispatches to a C function expecting a dense matrix. Instead, I reproduce the logic of the various C-level functions depending on the mode (e.g.igraph_i_adjacency_lower, all in theigraphproject,src/constructors.c).A few notes:
numpy2Dndarrays(which includenumpy.matrixobject) with a similar graceful import_function in a newsparse_matrixmodule to avoid cluttering the main module. Happy to discuss namespacing or alternativesFunnily enough, the concrete case that prompted me to make this PR is a weighted adjacency sparse matrix... so I would like to implement the weighted case as well, any suggestions how to call the class method in that case? Perhaps just
graph.AdjacencyWeighted?No tests written yet.
edit: Oh I just saw
Weighted_Adjacency.