Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
Merge plan/test-parts-full-timeout-1023 (parts: the mask's three hot loops take every step in place — the same bytes, and no kernel time in a process earlier tests left slow) into main, validated in sprite-gen/test-parts-full-timeout-1023
Soohong Kim04fd13fcdd5d
diff --cc tests/video/test_parts.pyindex ad05284,515136f..b3398a7--- a/tests/video/test_parts.py+++ b/tests/video/test_parts.py@@@ -240,7 -240,78 +241,79 @@@ def test_a_tail_behind_the_body_is_readassert sum(_crossed(t) for t in range(N)) >= 4+ # parts.py's three hot loops as first written, making new arrays every step: what they take each step in place now must+ # give, byte for byte.+ def _shift_as_written(m, dy, dx, fill=0):+ h, w = m.shape[:2]+ out = np.full_like(m, fill)+ out[max(0, dy):h + min(0, dy), max(0, dx):w + min(0, dx)] = m[max(0, -dy):h - max(0, dy), max(0, -dx):w - max(0, dx)]+ return out+++ def _least_as_written(seed, cost_to):+ d = np.where(seed, 0.0, np.inf).astype(np.float32)+ for k in range(parts.ITERATIONS):+ old = d+ for c, (dy, dx) in zip(cost_to, parts.NB):+ d = np.minimum(d, _shift_as_written(d, dy, dx, np.inf) + c)+ if k % 25 == 24 and np.array_equal(d, old):+ break+ return d+++ def _feet_as_written(self, a, b):+ top = int(parts.FEET_ROWS * a.shape[0])+ best = math.inf+ r = self.feet_shift+ for dy in range(-r, r + 1):+ for dx in range(-r, r + 1):+ bb = _shift_as_written(b, dy, dx)+ d = np.abs(a - bb).max(-1)[top:]+ on = ((a[..., 3] > 0.05) | (bb[..., 3] > 0.05))[top:]+ v = np.sort(d[on])+ if v.size:+ best = min(best, float(v[: max(1, int(0.75 * v.size))].mean()))+ return best+++ def _far_as_written(self, a, b):+ best = np.full(a.shape[:2], np.inf, np.float32)+ for dy, dx in parts._disk(self.search):+ best = np.minimum(best, np.abs(a - _shift_as_written(b, dy, dx)).max(-1))+ return best+++ def test_each_loop_a_mask_runs_gives_the_same_bytes_in_place_as_with_new_arrays_every_step(monkeypatch):+ # Every call of the three loops a frame's mask makes, of a frame filmed and of one made between two, is answered as+ # the loops first written answer it: the same dtype, the same bytes. The second least-cost reading's costs are+ # float64 (each side's own colours), and its distances are read in that precision, as they were.+ masker = _masker("side")+ calls = []++ def kept(name, loop):+ def call(*args):+ calls.append((name, args, loop(*args)))+ return calls[-1][2]+ return call++ monkeypatch.setattr(parts, "_least", kept("least", parts._least))+ monkeypatch.setattr(parts.Masker, "_feet", kept("feet", parts.Masker._feet))+ monkeypatch.setattr(parts.Masker, "_far", kept("far", parts.Masker._far))+ for t in (0, MADE[0]):+ part, _, _ = masker.mask_read(masker._read(_frame(t, "side")), t)+ assert part.any(), t+ as_written = {"least": _least_as_written, "feet": _feet_as_written, "far": _far_as_written}+ for name, args, got in calls:+ want = as_written[name](*args)+ if name == "feet":+ assert got == want+ else:+ assert (got.dtype, got.shape, got.tobytes()) == (want.dtype, want.shape, want.tobytes()), name+ assert {name for name, _, _ in calls} == {"least", "feet", "far"}+ assert {args[1][0].dtype.name for name, args, _ in calls if name == "least"} == {"float32", "float64"}++@pytest.mark.parametrize("reading", ["clip", "wrap"])@pytest.mark.parametrize("walker, rare", [("side", parts.RARE), ("back", parts.RARE), ("back_bushy", parts.RARE),("side", parts.RARE / 2), ("side", 2 * parts.RARE),