Skip to content

Commit

Permalink
Merge pull request graphnet-team#604 from RasmusOrsoe/warning_once_fix
Browse files Browse the repository at this point in the history
Warning once fix
  • Loading branch information
RasmusOrsoe authored Sep 25, 2023
2 parents 822940c + 68fe515 commit 9fb02f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/graphnet/models/graphs/edges/edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def forward(self, graph: Data) -> Data:
graph: a graph with edges
"""
if graph.edge_index is not None:
self.warnonce(
self.warning_once(
"GraphBuilder received graph with pre-existing "
"structure. Will overwrite."
)
Expand Down
12 changes: 7 additions & 5 deletions src/graphnet/models/graphs/graph_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ def forward( # type: ignore
if self._edge_definition is not None:
graph = self._edge_definition(graph)
else:
self.warnonce(

self.warning_once(
"""No EdgeDefinition provided.
Graphs will not have edges defined!""" # noqa
)
Expand Down Expand Up @@ -305,10 +306,11 @@ def _add_features_individually(
if feature not in ["x"]: # reserved for node features.
graph[feature] = graph.x[:, index].detach()
else:
self.warnonce(
"""Cannot assign graph['x']. This field is reserved
for node features. Please rename your input feature.""" # noqa
)
self.warning_once(
"""Cannot assign graph['x']. This field is reserved for
node features. Please rename your input feature."""
) # noqa

return graph

def _add_custom_labels(
Expand Down

0 comments on commit 9fb02f2

Please sign in to comment.