Skip to content

Commit

Permalink
Fix nx -> pyg conversion with no edges (#334)
Browse files Browse the repository at this point in the history
* Fix nx -> pyg conversion corner case when graph has no edges

* Update changelog
  • Loading branch information
anton-bushuiev committed Aug 23, 2023
1 parent e0d5d63 commit 93d2965
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
* [Bugfix] - [#305](https://github.com/a-r-j/graphein/pull/305) Fixes the construction of geometric features when beta-carbons or side chains are missing in non-glycine residues (for example in `H:CYS:104` in 3SE8).
* [Bugfix] - [#305](https://github.com/a-r-j/graphein/pull/305) Fixes data types of geometric feature vectors: `object` -> `float`.
* [Bugfix] - [#301](https://github.com/a-r-j/graphein/pull/301) Fixes the conversion of undirected NetworkX graph to directed PyG data.
* [Bugfix] - [#334](https://github.com/a-r-j/graphein/pull/334) Fixes the corner case of the NetworkX -> PyG conversion when input graph has no edges.

https://github.com/a-r-j/graphein/pull/334

#### Bugfixes
* Adds missing `stage` parameter to `graphein.ml.datasets.foldcomp_data.FoldCompDataModule.setup()`. [#310](https://github.com/a-r-j/graphein/pull/310)
Expand Down
3 changes: 2 additions & 1 deletion graphein/ml/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ def convert_nx_to_pyg(self, G: nx.Graph) -> Data:
data[key].append(value)

# Add edge features
edge_feature_names = list(G.edges(data=True))[0][2].keys()
edge_list = list(G.edges(data=True))
edge_feature_names = edge_list[0][2].keys() if edge_list else []
edge_feature_names = list(
filter(
lambda x: x in self.columns and x != "kind", edge_feature_names
Expand Down

0 comments on commit 93d2965

Please sign in to comment.