Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions python-wrapper/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"python.testing.pytestArgs": [
"tests",
"--include-neo4j-and-gds"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
5 changes: 4 additions & 1 deletion python-wrapper/src/neo4j_viz/gds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 18 additions & 4 deletions python-wrapper/tests/test_gds.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,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"], 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
Expand Down