Skip to content

Commit

Permalink
Turn off and rename by_second
Browse files Browse the repository at this point in the history
  • Loading branch information
nsbgn committed Aug 26, 2023
1 parent b7179b8 commit 842f29e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
11 changes: 6 additions & 5 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def test_query_specific_aspects(self):
results={TEST.wf1, TEST.wf2})

self.assertQuery(lang, graph,
[B], by_io=True, by_chronology=False, by_penultimate=False,
[B], by_io=True, by_chronology=False, by_penultimate_output=False,
results={TEST.wf1}
)
self.assertQuery(lang, graph,
Expand Down Expand Up @@ -251,7 +251,7 @@ def test_multiple_options_accept_union(self):
TEST.wf3: Source(A)
})

self.assertQuery(lang, workflows, [A], by_penultimate=False,
self.assertQuery(lang, workflows, [A], by_penultimate_output=False,
results={TEST.wf3})
self.assertQuery(lang, workflows, [B],
results={TEST.wf1, TEST.wf2})
Expand Down Expand Up @@ -417,7 +417,7 @@ def test_multiple_outputs(self):
graph.add((root, TF.output, B))
graph.add((A, TF["from"], C))
graph.add((B, TF["from"], C))
query = TransformationQuery(lang, graph, by_penultimate=False,
query = TransformationQuery(lang, graph, by_penultimate_output=False,
unfold_tree=False, skip_same_branch_matches=False)
result = list(query.chronology())
self.assertIn(result, [
Expand Down Expand Up @@ -455,8 +455,9 @@ def test_sensible_order(self):
graph.add((A, TF["from"], B))
graph.add((A, TF["from"], C))
graph.add((B, TF["from"], C))
query = TransformationQuery(lang, graph, by_penultimate=False,
unfold_tree=False, skip_same_branch_matches=False)
query = TransformationQuery(lang, graph,
by_penultimate_output=False, unfold_tree=False,
skip_same_branch_matches=False)
result = list(query.chronology())
self.assertIn(result, [
['?workflow :output ?_0.', '?_0 :from* ?_1.',
Expand Down
13 changes: 7 additions & 6 deletions transforge/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ def __init__(self, lang: Language, graph: Graph,
root: Node | None = None,
with_noncanonical_types: bool = False, by_io: bool = True,
by_types: bool = True, by_operators: bool = True,
by_chronology: bool = True, by_penultimate: bool = True,
by_second: bool = True,
by_chronology: bool = True,
by_penultimate_output: bool = True,
by_second_input: bool = False,
# By default, we turn the skip_same_branch_matches feature
# off because it does not seem to actually improve performance.
skip_same_branch_matches: bool = False,
Expand All @@ -89,8 +90,8 @@ def __init__(self, lang: Language, graph: Graph,
self.graph.parse_shortcuts()

self.by_io = by_io
self.by_penultimate = by_penultimate
self.by_second = by_second
self.by_penultimate_output = by_penultimate_output
self.by_second_input = by_second_input
self.by_types = by_types
self.by_operators = by_operators
self.by_chronology = by_chronology
Expand Down Expand Up @@ -289,7 +290,7 @@ def output_nodes(self) -> Iterator[str]:
Conditions for matching on input and outputs of the query.
"""
for outputv, output in self.outputs.items():
if self.by_penultimate:
if self.by_penultimate_output:
yield f"?workflow :output/:from? {outputv.n3()}."
else:
yield f"?workflow :output {outputv.n3()}."
Expand All @@ -305,7 +306,7 @@ def output_nodes(self) -> Iterator[str]:

def input_nodes(self) -> Iterator[str]:
for inputv, input in self.inputs.items():
if self.by_second:
if self.by_second_input:
yield f"?workflow :input/^:from? {inputv.n3()}."
else:
yield f"?workflow :input {inputv.n3()}."
Expand Down

0 comments on commit 842f29e

Please sign in to comment.