Skip to content

Commit 1e2764b

Browse files
rg314pre-commit-ci[bot]a-r-j
authored
Minor patch convert_nx_to_pyg #280 (#281)
* nx_to_pyg bug fix #280 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update changelog --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Arian Jamasb <arjamasb@gmail.com>
1 parent b308a58 commit 1e2764b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
#### Utils
3838
* [Improvement] - [#234](https://github.com/a-r-j/graphein/pull/234) - Adds `parse_aggregation_type` to retrieve aggregation functions.
3939

40+
#### RNA
41+
* [Bugfix] - [#281](https://github.com/a-r-j/graphein/pull/234) - Bugfix for nx->PyG conversion for graphs containing edges without "kind" attributes. Contribution by @rg314.
42+
4043
#### Constants
4144
* [Improvement] - [#234](https://github.com/a-r-j/graphein/pull/234) - Adds 1 to 3 mappings to `graphein.protein.resi_atoms`.
4245

graphein/ml/conversion.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,15 @@ def convert_nx_to_pyg(self, G: nx.Graph) -> Data:
305305
data["edge_index"] = edge_index
306306

307307
# Split edge index by edge kind
308-
kind_strs = np.array(list(map(lambda x: "_".join(x), data["kind"])))
308+
kind_strs = np.array(
309+
list(map(lambda x: "_".join(x), data.get("kind", [])))
310+
)
309311
for kind in set(kind_strs):
310312
key = f"edge_index_{kind}"
311313
if key in self.columns:
312314
mask = kind_strs == kind
313315
data[key] = edge_index[:, mask]
314-
if "kind" not in self.columns:
316+
if "kind" not in self.columns and data.get("kind"):
315317
del data["kind"]
316318

317319
# Convert everything possible to torch.Tensors

0 commit comments

Comments
 (0)