Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify tests for digraph and multidigraph #43

Merged

Conversation

jackboyla
Copy link
Contributor

@jackboyla jackboyla commented May 22, 2024

Me again 😇 I parameterised all unit tests so they run for DiGraph and MultiDiGraph.

Doing this I spotted a bug in my implementation for WHERE clauses for MultiDiGraphs. It's now fixed 😄.

Here's an example of it working. Previously it was returning empty results.

from grandcypher import GrandCypher
import networkx as nx

host = nx.MultiDiGraph()
host.add_node("a", name="Alice", age=25)
host.add_node("b", name="Bob", age=30)
host.add_node("c", name="Christine", age=30)
host.add_edge("a", "b", __labels__={"friend"}, years=1, friendly="very")
host.add_edge("b", "a", __labels__={"colleague"}, years=2)
host.add_edge("b", "a", __labels__={"mentor"}, years=4)
host.add_edge("b", "c", __labels__={"chef"}, years=12)

qry = """
MATCH (n)-[r]->(m)
WHERE n.name == "Alice"
RETURN n.name, m.name, r.__labels__, r.years, r.friendly
"""
res = GrandCypher(host).run(qry)
print(res)

# {
#      'n.name': ['Alice'], 
#      'm.name': ['Bob'], 
#      'r.__labels__': [{0: {'friend'}}], 
#      'r.years': [{0: 1}], 
#      'r.friendly': [{0: 'very'}]
# }

@j6k4m8
Copy link
Member

j6k4m8 commented May 22, 2024

wooo! nice bugfix, and great addition to the test suite!!

@j6k4m8 j6k4m8 merged commit b2b1771 into aplbrain:master May 22, 2024
6 checks passed
@jackboyla jackboyla deleted the unify-tests-for-digraph-and-multidigraph branch May 22, 2024 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants