Skip to content

Commit

Permalink
Fixes formatting issues related to change to Python 3.9 and minimum v…
Browse files Browse the repository at this point in the history
…ersion of Python 3 (#130)
  • Loading branch information
ilumsden authored May 24, 2024
1 parent 7175a27 commit 324e35b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
12 changes: 6 additions & 6 deletions hatchet/tests/graphframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,8 @@ def test_sub_decorator(monkeypatch, small_mock1, small_mock2, small_mock3):
output = gf4.tree(metric_column="time")

assert "0.000 C" in output
assert u"nan D ▶" in output
assert u"10.000 H ◀" in output
assert "nan D ▶" in output
assert "10.000 H ◀" in output

gf5 = gf1 - gf3

Expand All @@ -781,8 +781,8 @@ def test_sub_decorator(monkeypatch, small_mock1, small_mock2, small_mock3):
output = gf5.tree(metric_column="time (inc)")

assert "15.000 A" in output
assert u"5.000 C ◀" in output
assert u"10.000 H ◀" in output
assert "5.000 C ◀" in output
assert "10.000 H ◀" in output


def test_div_decorator(monkeypatch, small_mock1, small_mock2):
Expand All @@ -804,8 +804,8 @@ def test_div_decorator(monkeypatch, small_mock1, small_mock2):

assert "1.000 C" in output
assert "inf B" in output
assert u"nan D ▶" in output
assert u"10.000 H ◀" in output
assert "nan D ▶" in output
assert "10.000 H ◀" in output


def test_groupby_aggregate_simple(mock_dag_literal_module):
Expand Down
52 changes: 26 additions & 26 deletions hatchet/tests/query_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def test_sym_diff_query(mock_graph_literal):

def test_apply_cypher(mock_graph_literal):
gf = GraphFrame.from_literal(mock_graph_literal)
path = u"""MATCH (p)->(2, q)->("*", r)->(s)
path = """MATCH (p)->(2, q)->("*", r)->(s)
WHERE p."time (inc)" >= 30.0 AND NOT q."name" STARTS WITH "b"
AND r."name" =~ "[^b][a-z]+" AND s."name" STARTS WITH "gr"
"""
Expand All @@ -362,7 +362,7 @@ def test_apply_cypher(mock_graph_literal):

assert sorted(query.apply(gf)) == sorted(match)

path = u"""MATCH (p)->(".")->(q)->("*")
path = """MATCH (p)->(".")->(q)->("*")
WHERE p."time (inc)" >= 30.0 AND q."name" = "bar"
"""
match = [
Expand All @@ -375,14 +375,14 @@ def test_apply_cypher(mock_graph_literal):
query = CypherQuery(path)
assert sorted(query.apply(gf)) == sorted(match)

path = u"""MATCH (p)->(q)->(r)
path = """MATCH (p)->(q)->(r)
WHERE p."name" = "foo" AND q."name" = "bar" AND r."time" = 5.0
"""
match = [root, root.children[0], root.children[0].children[0]]
query = CypherQuery(path)
assert sorted(query.apply(gf)) == sorted(match)

path = u"""MATCH (p)->(q)->("+", r)
path = """MATCH (p)->(q)->("+", r)
WHERE p."name" = "foo" AND q."name" = "qux" AND r."time (inc)" > 15.0
"""
match = [
Expand All @@ -395,7 +395,7 @@ def test_apply_cypher(mock_graph_literal):
query = CypherQuery(path)
assert sorted(query.apply(gf)) == sorted(match)

path = u"""MATCH (p)->(q)
path = """MATCH (p)->(q)
WHERE p."time (inc)" > 100 OR p."time (inc)" <= 30 AND q."time (inc)" = 20
"""
roots = gf.graph.roots
Expand All @@ -408,21 +408,21 @@ def test_apply_cypher(mock_graph_literal):
query = CypherQuery(path)
assert sorted(query.apply(gf)) == sorted(match)

path = u"""MATCH (p)->("*", q)->(r)
path = """MATCH (p)->("*", q)->(r)
WHERE p."name" = "this" AND q."name" = "is" AND r."name" = "nonsense"
"""

query = CypherQuery(path)
assert query.apply(gf) == []

path = u"""MATCH (p)->("*")->(q)
path = """MATCH (p)->("*")->(q)
WHERE p."name" = 5 AND q."name" = "whatever"
"""
with pytest.raises(InvalidQueryFilter):
query = CypherQuery(path)
query.apply(gf)

path = u"""MATCH (p)->("*")->(q)
path = """MATCH (p)->("*")->(q)
WHERE p."time" = "badstring" AND q."name" = "whatever"
"""
query = CypherQuery(path)
Expand All @@ -440,14 +440,14 @@ def __init__(self):
"list"
] = DummyType()
gf = GraphFrame.from_literal(bad_field_test_dict)
path = u"""MATCH (p)->(q)->(r)
path = """MATCH (p)->(q)->(r)
WHERE p."name" = "foo" AND q."name" = "bar" AND p."list" = DummyType()
"""
with pytest.raises(InvalidQueryPath):
query = CypherQuery(path)
query.apply(gf)

path = u"""MATCH ("*")->(p)->(q)->("*")
path = """MATCH ("*")->(p)->(q)->("*")
WHERE p."name" = "bar" AND q."name" = "grault"
"""
match = [
Expand Down Expand Up @@ -494,39 +494,39 @@ def __init__(self):
query = CypherQuery(path)
assert sorted(query.apply(gf)) == sorted(match)

path = u"""MATCH ("*")->(p)->(q)->("+")
path = """MATCH ("*")->(p)->(q)->("+")
WHERE p."name" = "bar" AND q."name" = "grault"
"""
query = CypherQuery(path)
assert query.apply(gf) == []

gf.dataframe["time"] = np.NaN
gf.dataframe.at[gf.graph.roots[0], "time"] = 5.0
path = u"""MATCH ("*", p)
path = """MATCH ("*", p)
WHERE p."time" IS NOT NAN"""
match = [gf.graph.roots[0]]
query = CypherQuery(path)
assert query.apply(gf) == match

gf.dataframe["time"] = 5.0
gf.dataframe.at[gf.graph.roots[0], "time"] = np.NaN
path = u"""MATCH ("*", p)
path = """MATCH ("*", p)
WHERE p."time" IS NAN"""
match = [gf.graph.roots[0]]
query = CypherQuery(path)
assert query.apply(gf) == match

gf.dataframe["time"] = np.Inf
gf.dataframe.at[gf.graph.roots[0], "time"] = 5.0
path = u"""MATCH ("*", p)
path = """MATCH ("*", p)
WHERE p."time" IS NOT INF"""
match = [gf.graph.roots[0]]
query = CypherQuery(path)
assert query.apply(gf) == match

gf.dataframe["time"] = 5.0
gf.dataframe.at[gf.graph.roots[0], "time"] = np.Inf
path = u"""MATCH ("*", p)
path = """MATCH ("*", p)
WHERE p."time" IS INF"""
match = [gf.graph.roots[0]]
query = CypherQuery(path)
Expand All @@ -535,15 +535,15 @@ def __init__(self):
names = gf.dataframe["name"].copy()
gf.dataframe["name"] = None
gf.dataframe.at[gf.graph.roots[0], "name"] = names.iloc[0]
path = u"""MATCH ("*", p)
path = """MATCH ("*", p)
WHERE p."name" IS NOT NONE"""
match = [gf.graph.roots[0]]
query = CypherQuery(path)
assert query.apply(gf) == match

gf.dataframe["name"] = names
gf.dataframe.at[gf.graph.roots[0], "name"] = None
path = u"""MATCH ("*", p)
path = """MATCH ("*", p)
WHERE p."name" IS NONE"""
match = [gf.graph.roots[0]]
query = CypherQuery(path)
Expand All @@ -553,13 +553,13 @@ def __init__(self):
def test_cypher_and_compound_query(mock_graph_literal):
gf = GraphFrame.from_literal(mock_graph_literal)
compound_query1 = parse_cypher_query(
u"""
"""
{MATCH ("*", p) WHERE p."time (inc)" >= 20 AND p."time (inc)" <= 60}
AND {MATCH ("*", p) WHERE p."time (inc)" >= 60}
"""
)
compound_query2 = parse_cypher_query(
u"""
"""
MATCH ("*", p)
WHERE {p."time (inc)" >= 20 AND p."time (inc)" <= 60} AND {p."time (inc)" >= 60}
"""
Expand All @@ -576,13 +576,13 @@ def test_cypher_and_compound_query(mock_graph_literal):
def test_cypher_or_compound_query(mock_graph_literal):
gf = GraphFrame.from_literal(mock_graph_literal)
compound_query1 = parse_cypher_query(
u"""
"""
{MATCH ("*", p) WHERE p."time (inc)" = 5.0}
OR {MATCH ("*", p) WHERE p."time (inc)" = 10.0}
"""
)
compound_query2 = parse_cypher_query(
u"""
"""
MATCH ("*", p)
WHERE {p."time (inc)" = 5.0} OR {p."time (inc)" = 10.0}
"""
Expand All @@ -606,13 +606,13 @@ def test_cypher_or_compound_query(mock_graph_literal):
def test_cypher_xor_compound_query(mock_graph_literal):
gf = GraphFrame.from_literal(mock_graph_literal)
compound_query1 = parse_cypher_query(
u"""
"""
{MATCH ("*", p) WHERE p."time (inc)" >= 5.0 AND p."time (inc)" <= 10.0}
XOR {MATCH ("*", p) WHERE p."time (inc)" = 10.0}
"""
)
compound_query2 = parse_cypher_query(
u"""
"""
MATCH ("*", p)
WHERE {p."time (inc)" >= 5.0 AND p."time (inc)" <= 10.0} XOR {p."time (inc)" = 10.0}
"""
Expand Down Expand Up @@ -642,19 +642,19 @@ def test_leaf_query(small_mock2):
nonleaves = list(nodes - set(matches))
obj_query = QueryMatcher([{"depth": -1}])
str_query_numeric = parse_cypher_query(
u"""
"""
MATCH (p)
WHERE p."depth" = -1
"""
)
str_query_is_leaf = parse_cypher_query(
u"""
"""
MATCH (p)
WHERE p IS LEAF
"""
)
str_query_is_not_leaf = parse_cypher_query(
u"""
"""
MATCH (p)
WHERE p IS NOT LEAF
"""
Expand Down

0 comments on commit 324e35b

Please sign in to comment.