The result of a failed attack.
| 10 | |
| 11 | |
| 12 | class FailedAttackResult(AttackResult): |
| 13 | """The result of a failed attack.""" |
| 14 | |
| 15 | def __init__(self, original_result, perturbed_result=None): |
| 16 | perturbed_result = perturbed_result or original_result |
| 17 | super().__init__(original_result, perturbed_result) |
| 18 | |
| 19 | def str_lines(self, color_method=None): |
| 20 | lines = ( |
| 21 | self.goal_function_result_str(color_method), |
| 22 | self.original_text(color_method), |
| 23 | ) |
| 24 | return tuple(map(str, lines)) |
| 25 | |
| 26 | def goal_function_result_str(self, color_method=None): |
| 27 | failed_str = utils.color_text("[FAILED]", "red", color_method) |
| 28 | return ( |
| 29 | self.original_result.get_colored_output(color_method) + " --> " + failed_str |
| 30 | ) |