From 57d20f05022096c4d84a5e6941d79dcc9ffb3175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florentin=20D=C3=B6rre?= Date: Fri, 1 Aug 2025 14:10:56 +0200 Subject: [PATCH 1/3] Fix vscode test config for python --- .vscode/settings.json | 8 +++++++- python-wrapper/.vscode/settings.json | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 python-wrapper/.vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json index f13ada3a..3be2b8f7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,11 @@ { "python.analysis.extraPaths": [ "./python-wrapper/src" - ] + ], + "python.testing.pytestArgs": [ + "python-wrapper/tests/", + "--include-neo4j-and-gds" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true } diff --git a/python-wrapper/.vscode/settings.json b/python-wrapper/.vscode/settings.json new file mode 100644 index 00000000..00cd182b --- /dev/null +++ b/python-wrapper/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "python.testing.pytestArgs": [ + "tests", + "--include-neo4j-and-gds" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} From a52ba8aa2eb643d6e37cc3b09b7f337fd650561b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florentin=20D=C3=B6rre?= Date: Fri, 1 Aug 2025 14:11:28 +0200 Subject: [PATCH 2/3] Fix bug if size_prop is part of additional_properties --- changelog.md | 1 + python-wrapper/src/neo4j_viz/gds.py | 5 ++++- python-wrapper/tests/test_gds.py | 9 ++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index 5f4ee7e5..c0996e41 100644 --- a/changelog.md +++ b/changelog.md @@ -10,6 +10,7 @@ ## Bug fixes * Fixed a bug with `from_gds` where graphs with different relationship types would fail if they had different properties. +* Fixed a bug with `from_gds` where the additional property would be skipped if its also defined as the size property. ## Improvements diff --git a/python-wrapper/src/neo4j_viz/gds.py b/python-wrapper/src/neo4j_viz/gds.py index e9d68a72..1600d62d 100644 --- a/python-wrapper/src/neo4j_viz/gds.py +++ b/python-wrapper/src/neo4j_viz/gds.py @@ -148,7 +148,10 @@ def from_gds( if size_property is not None: if "size" in all_actual_node_properties and size_property != "size": node_props_df.rename(columns={"size": "__size"}, inplace=True) - node_props_df.rename(columns={size_property: "size"}, inplace=True) + if size_property not in additional_node_properties: + node_props_df.rename(columns={size_property: "size"}, inplace=True) + else: + node_props_df["size"] = node_props_df[size_property] for lbl, df in node_dfs.items(): if "labels" in all_actual_node_properties: diff --git a/python-wrapper/tests/test_gds.py b/python-wrapper/tests/test_gds.py index 528b8742..a44b0041 100644 --- a/python-wrapper/tests/test_gds.py +++ b/python-wrapper/tests/test_gds.py @@ -134,7 +134,6 @@ def test_from_gds_integration_all_properties(gds: Any) -> None: (2, 0, "REL", "REL", 3.0, 2.5), ] - def test_from_gds_mocked(mocker: MockerFixture) -> None: from graphdatascience import Graph, GraphDataScience @@ -196,14 +195,14 @@ def test_from_gds_mocked(mocker: MockerFixture) -> None: G = Graph() # type: ignore[call-arg] VG = from_gds( - gds, G, size_property="score", additional_node_properties=["component"], node_radius_min_max=(3.14, 1337) + gds, G, size_property="score", additional_node_properties=["component", "score"], node_radius_min_max=(3.14, 1337) ) assert len(VG.nodes) == 3 assert sorted(VG.nodes, key=lambda x: x.id) == [ - Node(id=0, caption="['A']", size=float(1337), properties=dict(labels=["A"], component=float(1))), - Node(id=1, caption="['C']", size=float(42), properties=dict(labels=["C"], component=float(4))), - Node(id=2, caption="['A', 'B']", size=float(3.14), properties=dict(labels=["A", "B"], component=float(2))), + Node(id=0, caption="['A']", size=float(1337), properties=dict(labels=["A"], component=float(1), score=float(1337))), + Node(id=1, caption="['C']", size=float(42), properties=dict(labels=["C"], component=float(4), score=float(42))), + Node(id=2, caption="['A', 'B']", size=float(3.14), properties=dict(labels=["A", "B"], component=float(2), score=float(3.14))), ] assert len(VG.relationships) == 3 From 14d62cfdd4b86acd2e6416777997821e01821f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florentin=20D=C3=B6rre?= Date: Fri, 1 Aug 2025 14:17:32 +0200 Subject: [PATCH 3/3] Format code --- python-wrapper/tests/test_gds.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/python-wrapper/tests/test_gds.py b/python-wrapper/tests/test_gds.py index a44b0041..3de38225 100644 --- a/python-wrapper/tests/test_gds.py +++ b/python-wrapper/tests/test_gds.py @@ -134,6 +134,7 @@ def test_from_gds_integration_all_properties(gds: Any) -> None: (2, 0, "REL", "REL", 3.0, 2.5), ] + def test_from_gds_mocked(mocker: MockerFixture) -> None: from graphdatascience import Graph, GraphDataScience @@ -195,14 +196,28 @@ def test_from_gds_mocked(mocker: MockerFixture) -> None: G = Graph() # type: ignore[call-arg] VG = from_gds( - gds, G, size_property="score", additional_node_properties=["component", "score"], node_radius_min_max=(3.14, 1337) + gds, + G, + size_property="score", + additional_node_properties=["component", "score"], + node_radius_min_max=(3.14, 1337), ) assert len(VG.nodes) == 3 assert sorted(VG.nodes, key=lambda x: x.id) == [ - Node(id=0, caption="['A']", size=float(1337), properties=dict(labels=["A"], component=float(1), score=float(1337))), + Node( + id=0, + caption="['A']", + size=float(1337), + properties=dict(labels=["A"], component=float(1), score=float(1337)), + ), Node(id=1, caption="['C']", size=float(42), properties=dict(labels=["C"], component=float(4), score=float(42))), - Node(id=2, caption="['A', 'B']", size=float(3.14), properties=dict(labels=["A", "B"], component=float(2), score=float(3.14))), + Node( + id=2, + caption="['A', 'B']", + size=float(3.14), + properties=dict(labels=["A", "B"], component=float(2), score=float(3.14)), + ), ] assert len(VG.relationships) == 3