docs: Plan an zwei Befunde aus Aufgabe 2 angepasst
- pyproject.toml braucht pythonpath, sonst ist das lokale Paket im Test nicht importierbar - der Mosaik-Test prüft jetzt den exakten Zuschnitt-Versatz statt nur der Eckkacheln Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1e089df4b4
commit
a94c09e279
1 file changed
+19
-6
@@ -292,6 +292,9 @@ dev = ["pytest>=8.3"]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
testpaths = ["tests"]
|
||||
# Ohne [build-system] behandelt uv das Projekt als virtuell und installiert das lokale
|
||||
# Paket nie; pythonpath legt tools/extract für die Tests auf den sys.path.
|
||||
pythonpath = ["."]
|
||||
```
|
||||
|
||||
Dann `cd tools/extract && uv sync`.
|
||||
@@ -367,19 +370,29 @@ Expected: PASS, 3 Tests
|
||||
|
||||
```python
|
||||
import numpy as np
|
||||
from leonida.coords import mosaic_origin_px
|
||||
from leonida.tiles import assemble
|
||||
|
||||
def fake_tile(row: int, col: int) -> np.ndarray:
|
||||
# Jede Kachel einfarbig, Farbe kodiert Zeile und Spalte.
|
||||
return np.full((256, 256, 3), (row, col, 7), dtype=np.uint8)
|
||||
"""Kodiert die globale Pixelposition, damit ein falscher Versatz auffällt."""
|
||||
ys, xs = np.mgrid[0:256, 0:256]
|
||||
gy = (row * 256 + ys) % 251
|
||||
gx = (col * 256 + xs) % 251
|
||||
return np.dstack([gy, gx, np.full((256, 256), 7)]).astype(np.uint8)
|
||||
|
||||
def test_assemble_crops_to_slice():
|
||||
mosaic = assemble(fake_tile)
|
||||
assert mosaic.shape == (3000, 3000, 3)
|
||||
# Nordwest-Ecke stammt aus Kachel (54, 60)
|
||||
assert tuple(mosaic[0, 0]) == (54, 60, 7)
|
||||
# Südost-Ecke stammt aus Kachel (65, 71)
|
||||
assert tuple(mosaic[-1, -1]) == (65, 71, 7)
|
||||
|
||||
def test_assemble_uses_the_exact_crop_offset():
|
||||
# Einfarbige Kacheln würden jeden Versatz von 0 bis 72 px durchgehen lassen.
|
||||
ox, oy = mosaic_origin_px()
|
||||
assert (ox, oy) == (24, 60)
|
||||
mosaic = assemble(fake_tile)
|
||||
r0, c0 = 54, 60
|
||||
for py, px in [(0, 0), (2999, 2999), (1234, 567)]:
|
||||
gy, gx = r0 * 256 + oy + py, c0 * 256 + ox + px
|
||||
assert tuple(mosaic[py, px]) == (gy % 251, gx % 251, 7)
|
||||
```
|
||||
|
||||
- [ ] **Step 7: Test laufen lassen, er muss scheitern**
|
||||
|
||||
Reference in new issue
Block a user