Skip to content

Commit 54faed3

Browse files
committed
fix(chain): flag unhandled binding collision #614
1 parent 63db90b commit 54faed3

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The changelog format is based on [Keep a Changelog](https://keepachangelog.com/e
66
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and all PyGraphistry-specific breaking changes are explictly noted here.
77

88
## [Development]
9+
10+
### Fixes
11+
12+
* Hop: Detect #614 of node id column name colliding with edge src/dst id column name and raise `NotImplementedError`
13+
914
### Docs
1015

1116
* Python remote mode notebook: Fixed engine results

graphistry/compute/hop.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ def hop(self: Plottable,
116116
g2 = self.materialize_nodes(engine=EngineAbstract(engine_concrete.value))
117117
logger.debug('materialized node/eddge types: %s, %s', type(g2._nodes), type(g2._edges))
118118

119+
if g2._node == g2._source:
120+
raise NotImplementedError(f'Not supported: Node id column cannot currently have the same name as edge src column: {g2._node}')
121+
if g2._node == g2._destination:
122+
raise NotImplementedError(f'Not supported: Node id column cannot currently have the same name as edge dst column: {g2._node}')
123+
119124
starting_nodes = nodes if nodes is not None else g2._nodes
120125

121126
if g2._edge is None:

graphistry/tests/compute/test_hop.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,28 @@ def test_hop_predicates_fail_destination_forward(self, g_long_forwards_chain: CG
415415
assert g2._edges[['s', 'd']].sort_values(['s', 'd']).to_dict(orient='records') == []
416416

417417

418+
def test_hop_binding_reuse():
419+
edges_df = pd.DataFrame({'s': ['a', 'b'], 'd': ['b', 'c']})
420+
nodes1_df = pd.DataFrame({'v': ['a', 'b', 'c']})
421+
nodes2_df = pd.DataFrame({'s': ['a', 'b', 'c']})
422+
nodes3_df = pd.DataFrame({'d': ['a', 'b', 'c']})
423+
424+
g1 = CGFull().nodes(nodes1_df, 'v').edges(edges_df, 's', 'd')
425+
g2 = CGFull().nodes(nodes2_df, 's').edges(edges_df, 's', 'd')
426+
g3 = CGFull().nodes(nodes3_df, 'd').edges(edges_df, 's', 'd')
427+
428+
try:
429+
g1_hop = g1.hop()
430+
g2_hop = g2.hop()
431+
g3_hop = g3.hop()
432+
except NotImplementedError:
433+
return
434+
435+
assert g1_hop._nodes.shape == g2_hop._nodes.shape
436+
assert g1_hop._edges.shape == g2_hop._edges.shape
437+
assert g1_hop._nodes.shape == g3_hop._nodes.shape
438+
assert g1_hop._edges.shape == g3_hop._edges.shape
439+
418440
def test_hop_simple_cudf_pd():
419441
nodes_df = pd.DataFrame({'id': [0, 1, 2], 'label': ['a', 'b', 'c']})
420442
edges_df = pd.DataFrame({'src': [0, 1, 2], 'dst': [1, 2, 0]})

0 commit comments

Comments
 (0)