Skip to content

Commit

Permalink
remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
ImogenBits committed Sep 30, 2023
1 parent 6678af3 commit 4c64437
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
22 changes: 0 additions & 22 deletions algobattle/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@


T = TypeVar("T")
_I = TypeVar("_I")
_S = TypeVar("_S")


def client() -> DockerClient:
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 1 addition & 10 deletions algobattle/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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."""

Expand Down

0 comments on commit 4c64437

Please sign in to comment.