From 4a347bffad474827177abd8316bf1cabf01699b4 Mon Sep 17 00:00:00 2001 From: Andreas Michael Hermansen <97125645+AMHermansen@users.noreply.github.com> Date: Fri, 22 Sep 2023 08:40:38 +0200 Subject: [PATCH 1/5] Fix warnonce bug Change warnonce to warning_once, which is the correct method. --- src/graphnet/models/graphs/edges/edges.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphnet/models/graphs/edges/edges.py b/src/graphnet/models/graphs/edges/edges.py index 28507058b..9f7844375 100644 --- a/src/graphnet/models/graphs/edges/edges.py +++ b/src/graphnet/models/graphs/edges/edges.py @@ -27,7 +27,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." ) From 431f3de8b54e03736368bbf848677cfb838118ee Mon Sep 17 00:00:00 2001 From: Andreas Michael Hermansen <97125645+AMHermansen@users.noreply.github.com> Date: Fri, 22 Sep 2023 08:42:14 +0200 Subject: [PATCH 2/5] Fix warnonce Change warnonce to warning_once which is the correct method. --- src/graphnet/models/graphs/graph_definition.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/graphnet/models/graphs/graph_definition.py b/src/graphnet/models/graphs/graph_definition.py index 48394ab73..275c56e57 100644 --- a/src/graphnet/models/graphs/graph_definition.py +++ b/src/graphnet/models/graphs/graph_definition.py @@ -116,7 +116,7 @@ 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!" ) @@ -252,7 +252,7 @@ def _add_features_individually( if feature not in ["x"]: # reserved for node features. graph[feature] = graph.x[:, index].detach() else: - self.warnonce( + self.warning_once( """Cannot assign graph['x']. This field is reserved for node features. Please rename your input feature.""" ) return graph From 41e0164df609a243be23c79f5e25ad4cdc372c17 Mon Sep 17 00:00:00 2001 From: Rasmus Oersoe Date: Sun, 24 Sep 2023 10:28:44 +0200 Subject: [PATCH 3/5] fix github mistake --- tests/utilities/test_model_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/utilities/test_model_config.py b/tests/utilities/test_model_config.py index 8979f0255..68ebd5c2a 100644 --- a/tests/utilities/test_model_config.py +++ b/tests/utilities/test_model_config.py @@ -18,7 +18,7 @@ def test_simple_model_config(path: str = "/tmp/simple_model.yml") -> None: - """Test saving, loading, and reconstructing simple model.""" + """Test saving, loading, and reconstructing using a simple model.""" # Construct single Model model = DynEdge( nb_inputs=9, From 5e87317b1bc004cdfc306e6a60e3fb6ebdd1be63 Mon Sep 17 00:00:00 2001 From: Rasmus Oersoe Date: Sun, 24 Sep 2023 10:32:37 +0200 Subject: [PATCH 4/5] Fix bracket --- src/graphnet/models/graphs/graph_definition.py | 4 +++- tests/utilities/test_model_config.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/graphnet/models/graphs/graph_definition.py b/src/graphnet/models/graphs/graph_definition.py index 042e54c58..aa73693ef 100644 --- a/src/graphnet/models/graphs/graph_definition.py +++ b/src/graphnet/models/graphs/graph_definition.py @@ -306,7 +306,9 @@ def _add_features_individually( graph[feature] = graph.x[:, index].detach() else: self.warning_once( - """Cannot assign graph['x']. This field is reserved for node features. Please rename your input feature.""" + """Cannot assign graph['x']. This field is reserved for + node features. Please rename your input feature.""" + ) # noqa return graph diff --git a/tests/utilities/test_model_config.py b/tests/utilities/test_model_config.py index 68ebd5c2a..8979f0255 100644 --- a/tests/utilities/test_model_config.py +++ b/tests/utilities/test_model_config.py @@ -18,7 +18,7 @@ def test_simple_model_config(path: str = "/tmp/simple_model.yml") -> None: - """Test saving, loading, and reconstructing using a simple model.""" + """Test saving, loading, and reconstructing simple model.""" # Construct single Model model = DynEdge( nb_inputs=9, From 9e2be1440e5eba2345bfb4303a03d47beede5582 Mon Sep 17 00:00:00 2001 From: Rasmus Oersoe Date: Sun, 24 Sep 2023 10:37:02 +0200 Subject: [PATCH 5/5] code climate --- src/graphnet/models/graphs/graph_definition.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/graphnet/models/graphs/graph_definition.py b/src/graphnet/models/graphs/graph_definition.py index aa73693ef..9c4db4d47 100644 --- a/src/graphnet/models/graphs/graph_definition.py +++ b/src/graphnet/models/graphs/graph_definition.py @@ -150,7 +150,8 @@ def forward( # type: ignore else: self.warning_once( - "No EdgeDefinition provided. Graphs will not have edges defined!" + """No EdgeDefinition provided. + Graphs will not have edges defined!""" # noqa ) # Attach data path - useful for Ensemble datasets.