-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Read/write/generate a basic graph using UCINET DL format #2052
Conversation
Functions and tests for UCINET DL format. Currently supports only 'fullmatrix' format for data.
There are already some functions for reading and writing e.g. adjacency matrices, perhaps those can be used so you don't need to reimplement an adjacency matrix reader/writer? |
The test errors all seem to relate to a print statement left in place. How likely are people to want the "variant" forms of the UCINET DL format? What is the best way to handle that? Are there easy converters from one variant to another? |
Remove print statements, shorten lines under 80 characters per line.
Sorry, I cleaned the code and I hope the test will pass now. I was thinking of two kind of "variants" :
I plan to implement all of these variants in a near future. Maybe you would prefer to wait for the whole and complete implementation ? |
@jfinkels has a good idea here to use existing readers to help make writing this easier. I looked at the formats for UCINET DL
They all are basic text files with a header and then data. Perhaps the simplest approach is to write a function that will parse the header and dispatch based on that. e.g. for
The steps would be
In that case we already have an edgelist reader. For matrix formats we could fairly simply use either one of
For writing data a similar approach could be used. |
To parse data, use functions already existing in Numpy and Networkx such as genfromtxt and from_numpy_matrix.
Add `nodelist1` and `nodelist1b` data format support. Also adds support for embedded labels.
Use `to_numpy_matrix` in `generate_ucinet` Update tests of `generate_ucinet`
Fix bugs occurring with Python3 (bytes string for genfromtxt)
Thank you for your advices. I committed some changes according to this. However the checks failed because of Numpy's import : how should I import it ? |
Since the pypy standard build doesn't include numpy, you'll have to make the tests skip your module when numpy is not available. Any module that uses numpy should have the code to skip tests at the bottom, for example the bottom of graphmatrix.py |
Add support for `edgelist1` format + fixture for Numpy import
Fixture Nose with NumPy and fix reading irregular matrices (in genfromtxt).
Thanks for your work on this @Temigo! Unfortunately we haven't reviewed this in a long time, sorry about that! A lot of things have changed in networkx in the last 7 years so we would need to put in some effort to make this PR mergeable. I think we also need to be a bit conservative in adding new I/O formats in networkx, so the code can be maintainable. I have added this to #7099 that tracks future wishlist/good ideas/maybes and once we have a decision we can move forward with the implementation bits. Thanks again! |
Functions and tests for UCINET DL format.
(Currently supports only 'fullmatrix' format for data. There are many variants for UCINET DL format, this implementation only covers the basic one for now.)
This is related to issue #2051. Thanks !