Skip to content

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

@Debadri-das

Description

@Debadri-das

weather_model_graphs.save.to_pyg() modifies the input networkx graph in place by deleting node attributes that are not included in node_features.

The save/export function is often anticipated to be non-destructive; however, the current implementation of to_pyg() directly removes characteristics from the original graph object prior to its conversion to PyTorch Geometric format.

Expected behavior

Calling to_pyg() should export/serialize the graph without mutating the caller’s original networkx.DiGraph.

Actual behavior

Inside src/weather_model_graphs/save.py, to_pyg() removes node attributes from the original graph:

for node in graph.nodes:
    for attr in list(graph.nodes[node].keys()):
        if attr not in node_features:
            del graph.nodes[node][attr]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions