Skip to content

Commit

Permalink
Better fallback of values for oracles
Browse files Browse the repository at this point in the history
  • Loading branch information
niknetniko committed Sep 20, 2023
1 parent 6e8eff1 commit 1cdafd3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 7 additions & 3 deletions tested/oracles/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ class BooleanEvalResult:
dsl_actual: str | None = None

def to_oracle_result(
self, bundle: Bundle, channel: NormalOutputChannel
self,
bundle: Bundle,
channel: NormalOutputChannel,
fallback_actual: str,
fallback_expected: str,
) -> OracleResult:
if isinstance(self.result, Status):
status = self.result

Check warning on line 89 in tested/oracles/common.py

View check run for this annotation

Codecov / codecov/patch

tested/oracles/common.py#L89

Added line #L89 was not covered by tests
Expand All @@ -92,14 +96,14 @@ def to_oracle_result(
parsed_statement = parse_string(self.dsl_expected, True)
readable_expected = generate_statement(bundle, parsed_statement)
else:
readable_expected = ""
readable_expected = fallback_expected
if self.readable_actual:
readable_actual = self.readable_actual
elif self.dsl_actual:
parsed_statement = parse_string(self.dsl_actual, True)
readable_actual = generate_statement(bundle, parsed_statement)
else:
readable_actual = ""
readable_actual = fallback_actual
messages = self.messages

if isinstance(channel, ExceptionOutputChannel):
Expand Down
4 changes: 3 additions & 1 deletion tested/oracles/programmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,6 @@ def evaluate(
assert isinstance(result, BooleanEvalResult)
evaluation_result = result

return evaluation_result.to_oracle_result(config.bundle, channel)
return evaluation_result.to_oracle_result(
config.bundle, channel, readable_actual, readable_expected
)
2 changes: 1 addition & 1 deletion tested/oracles/specific.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ def evaluate(
messages=[staff_message, student_message],
)

return actual.to_oracle_result(config.bundle, channel)
return actual.to_oracle_result(config.bundle, channel, "", "")

0 comments on commit 1cdafd3

Please sign in to comment.