From 4c644373661cfeff923df96b20ebae8a29449b99 Mon Sep 17 00:00:00 2001 From: Imogen Date: Sun, 1 Oct 2023 01:07:19 +0200 Subject: [PATCH] remove dead code --- algobattle/program.py | 22 ---------------------- algobattle/util.py | 11 +---------- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/algobattle/program.py b/algobattle/program.py index 395e36a9..f62f5e90 100644 --- a/algobattle/program.py +++ b/algobattle/program.py @@ -46,8 +46,6 @@ T = TypeVar("T") -_I = TypeVar("_I") -_S = TypeVar("_S") def client() -> DockerClient: @@ -596,26 +594,6 @@ class Solver(Program): role: ClassVar[Role] = Role.solver - def _encode_input(self, input: Path, max_size: int, instance: Instance | None) -> None: - assert instance is not None - instance.encode(input / "instance", self.role) - - def _parse_output(self, output: Path, max_size: int, instance: Instance | None) -> Solution[Instance]: - assert instance is not None - try: - solution = self.problem.solution_cls.decode(output / "solution", max_size, self.role, instance) - except EncodingError: - raise - except Exception as e: - raise EncodingError("Error thrown while decoding the solution.", detail=str(e)) from e - try: - solution.validate_solution(instance, Role.solver) - except ValidationError: - raise - except Exception as e: - raise ValidationError("Unknown error during solution validation.", detail=str(e)) from e - return solution - async def run( self, instance: Instance, diff --git a/algobattle/util.py b/algobattle/util.py index 6e7c2c39..1c87cb07 100644 --- a/algobattle/util.py +++ b/algobattle/util.py @@ -13,7 +13,7 @@ from tempfile import TemporaryDirectory from traceback import format_exception from types import ModuleType -from typing import Any, Iterable, LiteralString, TypeVar, Self +from typing import Any, LiteralString, TypeVar, Self from pydantic import ( ConfigDict, @@ -132,15 +132,6 @@ class RunningTimer: timeout: float | None -def flat_intersperse(iterable: Iterable[Iterable[T]], element: T) -> Iterable[T]: - """Inserts `element` between each iterator in `iterable`.""" - iterator = iter(iterable) - yield from next(iterator) - for item in iterator: - yield element - yield from item - - class AlgobattleBaseException(Exception): """Base exception class for errors used by the algobattle package."""