From d105145760718673f1afeddebf72face87dfb1cf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 10 Nov 2025 13:30:49 +0000 Subject: [PATCH 1/3] Initial plan From 9fe206ac8e86b90a764993a09105fbf37d6bcbd5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 10 Nov 2025 13:43:43 +0000 Subject: [PATCH 2/3] Change default for override parameter on VG.color_nodes from False to True Co-authored-by: FlorentinD <15693197+FlorentinD@users.noreply.github.com> --- .../src/neo4j_viz/visualization_graph.py | 2 +- python-wrapper/tests/test_colors.py | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/python-wrapper/src/neo4j_viz/visualization_graph.py b/python-wrapper/src/neo4j_viz/visualization_graph.py index ecc40ab..49efcdf 100644 --- a/python-wrapper/src/neo4j_viz/visualization_graph.py +++ b/python-wrapper/src/neo4j_viz/visualization_graph.py @@ -294,7 +294,7 @@ def color_nodes( property: Optional[str] = None, colors: Optional[ColorsType] = None, color_space: ColorSpace = ColorSpace.DISCRETE, - override: bool = False, + override: bool = True, ) -> None: """ Color the nodes in the graph based on either a node field, or a node property. diff --git a/python-wrapper/tests/test_colors.py b/python-wrapper/tests/test_colors.py index adc1395..dff4d2c 100644 --- a/python-wrapper/tests/test_colors.py +++ b/python-wrapper/tests/test_colors.py @@ -254,3 +254,39 @@ def test_color_nodes_unhashable() -> None: VG = VisualizationGraph(nodes=nodes, relationships=[]) with pytest.raises(ValueError, match="Unable to color nodes by unhashable property type ''"): VG.color_nodes(property="list_of_lists", colors=["#000000"]) + + +def test_color_nodes_default_override() -> None: + """Test that the default value of override is True (colors are overridden by default).""" + nodes = [ + Node(id="4:d09f48a4-5fca-421d-921d-a30a896c604d:0", caption="Person", color="#FF0000"), + Node(id="4:d09f48a4-5fca-421d-921d-a30a896c604d:6", caption="Product", color="#FF0000"), + Node(id="4:d09f48a4-5fca-421d-921d-a30a896c604d:11", caption="Product", color="#FF0000"), + ] + + VG = VisualizationGraph(nodes=nodes, relationships=[]) + + # Call without specifying override - should use default (True) and override existing colors + VG.color_nodes(field="caption", colors={"Person": "#000000", "Product": "#00FF00"}) + + assert VG.nodes[0].color == Color("#000000") + assert VG.nodes[1].color == Color("#00ff00") + assert VG.nodes[2].color == Color("#00ff00") # Should be overridden to #00ff00 + + +def test_color_nodes_override_false() -> None: + """Test that override=False preserves existing colors.""" + nodes = [ + Node(id="4:d09f48a4-5fca-421d-921d-a30a896c604d:0", caption="Person", color="#FF0000"), + Node(id="4:d09f48a4-5fca-421d-921d-a30a896c604d:6", caption="Product", color="#FF0000"), + Node(id="4:d09f48a4-5fca-421d-921d-a30a896c604d:11", caption="Product"), + ] + + VG = VisualizationGraph(nodes=nodes, relationships=[]) + + # Call with override=False - should preserve existing colors + VG.color_nodes(field="caption", colors={"Person": "#000000", "Product": "#00FF00"}, override=False) + + assert VG.nodes[0].color == Color("#ff0000") # Should keep existing color + assert VG.nodes[1].color == Color("#ff0000") # Should keep existing color + assert VG.nodes[2].color == Color("#00ff00") # Should get new color (no existing color) From 7628c55eb6be74aa02f163dd47648dd0e2703a49 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 10 Nov 2025 13:55:21 +0000 Subject: [PATCH 3/3] Add changelog entry for override parameter default change Co-authored-by: FlorentinD <15693197+FlorentinD@users.noreply.github.com> --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 5d02439..36f223a 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ ## Breaking changes * Removed `table` property from nodes and relationships returned from `from_snowflake`, the table is represented by the `caption` field. +* Changed default value of `override` parameter in `VisualizationGraph.color_nodes()` from `False` to `True`. The method now overrides existing node colors by default. To preserve existing colors, explicitly pass `override=False`. ## New features