From f0f8676eaaed6324c6c7c91d1176edb0dfb164ca Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sun, 21 Jun 2026 17:35:51 +0200 Subject: [PATCH] feat: gate route_tuple helper Co-Authored-By: Claude Opus 4.8 --- gates/gate.py | 15 +++++++++++++++ tests/test_gate.py | 11 +++++++++++ 2 files changed, 26 insertions(+) create mode 100644 gates/gate.py create mode 100644 tests/test_gate.py diff --git a/gates/gate.py b/gates/gate.py new file mode 100644 index 0000000..d7bcfc7 --- /dev/null +++ b/gates/gate.py @@ -0,0 +1,15 @@ +# gates/gate.py +import io +import math + +import numpy as np +import torch +from PIL import Image + +from . import gate_bus + +MAX_ROUTES = 10 + + +def route_tuple(chosen, image, blocker, max_routes=MAX_ROUTES): + return tuple(image if i == chosen else blocker for i in range(max_routes)) diff --git a/tests/test_gate.py b/tests/test_gate.py new file mode 100644 index 0000000..2af7a61 --- /dev/null +++ b/tests/test_gate.py @@ -0,0 +1,11 @@ +# tests/test_gate.py +from gates import gate + +def test_route_tuple_places_image_at_chosen(): + B = object() + t = gate.route_tuple(2, "IMG", B, max_routes=5) + assert t == (B, B, "IMG", B, B) + +def test_route_tuple_length_is_max(): + B = object() + assert len(gate.route_tuple(0, "IMG", B, max_routes=10)) == 10