Skip to content

Commit 52dd86e

Browse files
committed
changing name of argument from verbose to return_inputs
1 parent b01548a commit 52dd86e

File tree

3 files changed

+42
-40
lines changed

3 files changed

+42
-40
lines changed

pydra/engine/core.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -532,17 +532,17 @@ def done(self):
532532
return True
533533
return False
534534

535-
def _combined_output(self, verbose=False):
535+
def _combined_output(self, return_inputs=False):
536536
combined_results = []
537537
for (gr, ind_l) in self.state.final_combined_ind_mapping.items():
538538
combined_results_gr = []
539539
for ind in ind_l:
540540
result = load_result(self.checksum_states(ind), self.cache_locations)
541541
if result is None:
542542
return None
543-
if verbose is True or verbose == "val":
543+
if return_inputs is True or return_inputs == "val":
544544
result = (self.state.states_val[ind], result)
545-
elif verbose == "ind":
545+
elif return_inputs == "ind":
546546
result = (self.state.states_ind[ind], result)
547547
combined_results_gr.append(result)
548548
combined_results.append(combined_results_gr)
@@ -552,15 +552,15 @@ def _combined_output(self, verbose=False):
552552
else:
553553
return combined_results
554554

555-
def result(self, state_index=None, verbose=False):
555+
def result(self, state_index=None, return_inputs=False):
556556
"""
557557
Retrieve the outcomes of this particular task.
558558
559559
Parameters
560560
----------
561561
state_index : :obj: `int`
562562
index of the element for task with splitter and multiple states
563-
verbose : :obj: `bool`, :obj:`str`
563+
return_inputs : :obj: `bool`, :obj:`str`
564564
if True or "val" result is returned together with values of the input fields,
565565
if "ind" result is returned together with indices of the input fields
566566
@@ -575,29 +575,31 @@ def result(self, state_index=None, verbose=False):
575575
if state_index is None:
576576
# if state_index=None, collecting all results
577577
if self.state.combiner:
578-
return self._combined_output(verbose=verbose)
578+
return self._combined_output(return_inputs=return_inputs)
579579
else:
580580
results = []
581581
for checksum in self.checksum_states():
582582
result = load_result(checksum, self.cache_locations)
583583
if result is None:
584584
return None
585585
results.append(result)
586-
if verbose is True or verbose == "val":
586+
if return_inputs is True or return_inputs == "val":
587587
return list(zip(self.state.states_val, results))
588-
elif verbose == "ind":
588+
elif return_inputs == "ind":
589589
return list(zip(self.state.states_ind, results))
590590
else:
591591
return results
592592
else: # state_index is not None
593593
if self.state.combiner:
594-
return self._combined_output(verbose=verbose)[state_index]
594+
return self._combined_output(return_inputs=return_inputs)[
595+
state_index
596+
]
595597
result = load_result(
596598
self.checksum_states(state_index), self.cache_locations
597599
)
598-
if verbose is True or verbose == "val":
600+
if return_inputs is True or return_inputs == "val":
599601
return (self.state.states_val[state_index], result)
600-
elif verbose == "ind":
602+
elif return_inputs == "ind":
601603
return (self.state.states_ind[state_index], result)
602604
else:
603605
return result
@@ -606,13 +608,13 @@ def result(self, state_index=None, verbose=False):
606608
raise ValueError("Task does not have a state")
607609
checksum = self.checksum
608610
result = load_result(checksum, self.cache_locations)
609-
if verbose is True or verbose == "val":
611+
if return_inputs is True or return_inputs == "val":
610612
inputs_val = {
611613
f"{self.name}.{inp}": getattr(self.inputs, inp)
612614
for inp in self.input_names
613615
}
614616
return (inputs_val, result)
615-
elif verbose == "ind":
617+
elif return_inputs == "ind":
616618
inputs_ind = {f"{self.name}.{inp}": None for inp in self.input_names}
617619
return (inputs_ind, result)
618620
else:

pydra/engine/tests/test_node_task.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,15 @@ def test_task_nostate_1(plugin):
368368
# checking the results
369369
results = nn.result()
370370
assert results.output.out == 5
371-
# checking the verbose option, either verbose=True, or verbose="val",
371+
# checking the return_inputs option, either is return_inputs is True, or "val",
372372
# it should give values of inputs that corresponds to the specific element
373-
results_verb = nn.result(verbose=True)
374-
results_verb_val = nn.result(verbose="val")
373+
results_verb = nn.result(return_inputs=True)
374+
results_verb_val = nn.result(return_inputs="val")
375375
assert results_verb[0] == results_verb_val[0] == {"NA.a": 3}
376376
assert results_verb[1].output.out == results_verb_val[1].output.out == 5
377-
# checking the verbose option verbose="ind"
377+
# checking the return_inputs option return_inputs="ind"
378378
# it should give indices of inputs (instead of values) for each element
379-
results_verb_ind = nn.result(verbose="ind")
379+
results_verb_ind = nn.result(return_inputs="ind")
380380
assert results_verb_ind[0] == {"NA.a": None}
381381
assert results_verb_ind[1].output.out == 5
382382

@@ -722,17 +722,17 @@ def test_task_state_1(plugin):
722722
for i, res in enumerate(expected):
723723
assert results[i].output.out == res[1]
724724

725-
# checking the verbose option, either verbose=True, or verbose="val",
725+
# checking the return_inputs option, either return_inputs is True or "val",
726726
# it should give values of inputs that corresponds to the specific element
727-
results_verb = nn.result(verbose=True)
728-
results_verb_val = nn.result(verbose="val")
727+
results_verb = nn.result(return_inputs=True)
728+
results_verb_val = nn.result(return_inputs="val")
729729
for i, res in enumerate(expected):
730730
assert (results_verb[i][0], results_verb[i][1].output.out) == res
731731
assert (results_verb_val[i][0], results_verb_val[i][1].output.out) == res
732732

733-
# checking the verbose option verbose="ind"
733+
# checking the return_inputs option return_inputs="ind"
734734
# it should give indices of inputs (instead of values) for each element
735-
results_verb_ind = nn.result(verbose="ind")
735+
results_verb_ind = nn.result(return_inputs="ind")
736736
expected_ind = [({"NA.a": 0}, 5), ({"NA.a": 1}, 7)]
737737
for i, res in enumerate(expected_ind):
738738
assert (results_verb_ind[i][0], results_verb_ind[i][1].output.out) == res
@@ -815,17 +815,17 @@ def test_task_state_2(
815815
for i, res in enumerate(expected):
816816
assert results[i].output.out == res[1]
817817

818-
# checking the verbose option, either verbose=True, or verbose="val",
818+
# checking the return_inputs option, either return_inputs is True or "val",
819819
# it should give values of inputs that corresponds to the specific element
820-
results_verb = nn.result(verbose=True)
821-
results_verb_val = nn.result(verbose="val")
820+
results_verb = nn.result(return_inputs=True)
821+
results_verb_val = nn.result(return_inputs="val")
822822
for i, res in enumerate(expected):
823823
assert (results_verb[i][0], results_verb[i][1].output.out) == res
824824
assert (results_verb_val[i][0], results_verb_val[i][1].output.out) == res
825825

826-
# checking the verbose option verbose="ind"
826+
# checking the return_inputs option return_inputs="ind"
827827
# it should give indices of inputs (instead of values) for each element
828-
results_verb_ind = nn.result(verbose="ind")
828+
results_verb_ind = nn.result(return_inputs="ind")
829829
for i, res in enumerate(expected_ind):
830830
assert (results_verb_ind[i][0], results_verb_ind[i][1].output.out) == res
831831

@@ -1040,16 +1040,16 @@ def test_task_state_comb_1(plugin):
10401040

10411041
expected = [({"NA.a": 3}, 5), ({"NA.a": 5}, 7)]
10421042
expected_ind = [({"NA.a": 0}, 5), ({"NA.a": 1}, 7)]
1043-
# checking the verbose option, either verbose=True, or verbose="val",
1043+
# checking the return_inputs option, either return_inputs is True or "val",
10441044
# it should give values of inputs that corresponds to the specific element
1045-
results_verb = nn.result(verbose=True)
1046-
results_verb_val = nn.result(verbose="val")
1045+
results_verb = nn.result(return_inputs=True)
1046+
results_verb_val = nn.result(return_inputs="val")
10471047
for i, res in enumerate(expected):
10481048
assert (results_verb[i][0], results_verb[i][1].output.out) == res
10491049
assert (results_verb_val[i][0], results_verb_val[i][1].output.out) == res
1050-
# checking the verbose option verbose="ind"
1050+
# checking the return_inputs option return_inputs="ind"
10511051
# it should give indices of inputs (instead of values) for each element
1052-
results_verb_ind = nn.result(verbose="ind")
1052+
results_verb_ind = nn.result(return_inputs="ind")
10531053
for i, res in enumerate(expected_ind):
10541054
assert (results_verb_ind[i][0], results_verb_ind[i][1].output.out) == res
10551055

@@ -1172,9 +1172,9 @@ def test_task_state_comb_2(
11721172

11731173
# checking the results
11741174
results = nn.result()
1175-
# checking the verbose option, either verbose=True, or verbose="val",
1175+
# checking the return_inputs option, either return_inputs is True or "val",
11761176
# it should give values of inputs that corresponds to the specific element
1177-
results_verb = nn.result(verbose=True)
1177+
results_verb = nn.result(return_inputs=True)
11781178

11791179
if nn.state.splitter_rpn_final:
11801180
for i, res in enumerate(expected):

pydra/engine/tests/test_workflow.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,17 +592,17 @@ def test_wf_st_3(plugin):
592592
for i, res in enumerate(expected):
593593
assert results[i].output.out == res[1]
594594

595-
# checking the verbose option, either verbose=True, or verbose="val",
595+
# checking the return_inputs option, either return_inputs is True or "val",
596596
# it should give values of inputs that corresponds to the specific element
597-
results_verb = wf.result(verbose=True)
598-
results_verb_val = wf.result(verbose="val")
597+
results_verb = wf.result(return_inputs=True)
598+
results_verb_val = wf.result(return_inputs="val")
599599
for i, res in enumerate(expected):
600600
assert (results_verb[i][0], results_verb[i][1].output.out) == res
601601
assert (results_verb_val[i][0], results_verb_val[i][1].output.out) == res
602602

603-
# checking the verbose option verbose="ind"
603+
# checking the return_inputs option return_inputs="ind"
604604
# it should give indices of inputs (instead of values) for each element
605-
results_verb_ind = wf.result(verbose="ind")
605+
results_verb_ind = wf.result(return_inputs="ind")
606606
for i, res in enumerate(expected_ind):
607607
assert (results_verb_ind[i][0], results_verb_ind[i][1].output.out) == res
608608

0 commit comments

Comments
 (0)