This repository has been archived by the owner on Jul 11, 2024. It is now read-only.
topologic.io.from_dataset ignoring empty directed graphs and creating undirected instead #30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
from_dataset
function was doing a truthiness check on the graph object, instead of specifically testing for Noneness. This meant that our tests and behaviors around enriching already populated graph objects was working fine, but it also meant that we would fail in situations where a fresh nx.Graph or nx.DiGraph object were to be passed in instead - and fail by ignoring them and creating a new graph entirely.This would be very subtle to find, since most of our tests around around undirected graphs and we wouldn't notice an empty nx.Graph not being used in favor of another empty nx.Graph (that was then populated). The problem manifests much more clearly when trying to populate a directed graph instead and receiving an undirected graph in return!
In addition to fixing the bug, I added a backwards compatible flag (
is_directed=False)
tofrom_file
such that users of directed graphs don't have to go the whole way to the full blownfrom_dataset
just to use a directed graph. The current behavior is maintained in that it defaults to an undirected graph, but users can now specifically request creation of a directed graph instead.Closes #29