Skip to content

fix: to_pyg no longer mutates the caller's input graph - #151

Open
BHUMIKA-VV wants to merge 1 commit into
mllam:mainfrom
BHUMIKA-VV:fix/to-pyg-mutates-input-graph
Open

BHUMIKA-VV wants to merge 1 commit into
mllam:mainfrom
BHUMIKA-VV:fix/to-pyg-mutates-input-graph

Conversation

@BHUMIKA-VV

@BHUMIKA-VV BHUMIKA-VV commented Sep 1, 2026

Copy link
Copy Markdown

Describe your changes

to_pyg trimmed each node's attribute dict down to node_features by
deleting keys directly on the graph object passed in by the caller — a
destructive side effect for what should be a read-only export function.
This works on a copy of the graph instead, so the caller's original graph
object is left untouched. Added a regression test
(test_to_pyg_does_not_mutate_input_graph) that fails on main and
passes with this fix.

Issue Link

Fixes #139

Type of change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Checklist before requesting a review

  • My branch is up-to-date with the target branch
  • I have performed a self-review of my code
  • I have placed in-line comments to clarify the intent of any hard-to-understand passages of my code
  • I have added tests that prove my fix is effective or that my feature works
  • I have given the PR a name that clearly describes the change, written in imperative form

`to_pyg` trimmed each node's attribute dict down to `node_features` by
deleting keys in place on the graph passed in by the caller. Work on a
copy instead, and add a regression test.

Refs mllam#139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

save.to_pyg() mutates the input graph by deleting node attributes in place

1 participant