fixed commetn from songxiao

This commit is contained in:
ykcheungab
2026-09-25 17:46:37 +08:00
parent 6effe74172
commit 12781854ca
56 changed files with 4935 additions and 419 deletions
+20 -4
View File
@@ -245,14 +245,22 @@ def test_the_finger_adapter_can_be_built_from_a_domain(scene):
assert adapter.map_x is not None and adapter.map_y is not None, (
"the domain must carry the unroll map for the adapter to use"
)
assert domain.source_hw == (288, 512), domain.source_hw
# The map states its own source frame, and that frame is the raw 1280x720 frame scaled by
# ``source_scale`` (0.42 -> 538x302), *not* the 300x280 domain the adapter publishes. Pinning
# the relationship rather than one literal keeps this about the convention: a map whose
# coordinates were stated in native pixels would fail here.
scale = domain.source_scale
assert scale == 0.42, scale
assert domain.source_hw == (round(720 * scale), round(1280 * scale)), domain.source_hw
assert domain.source_hw != domain.shape_hw
def test_the_shipped_map_cannot_be_applied_to_the_shipped_flow():
"""Why the app must not remap the finger's flow: the map is domain→*source*.
The unroll map is the same size as the UV domain, but its values are pixel
coordinates in the 512x288 source image — not in the 300x280 domain. The live
coordinates in the scaled source image (538x302 at ``source_scale`` 0.42) — not in the
300x280 domain. The live
flow is already computed on the unrolled frame, so feeding it through this map
would be a double remap: it would index the flow at source-pixel coordinates.
This test pins the reason the app passes no map, so a later "improvement" has to
@@ -272,15 +280,23 @@ def test_the_shipped_map_cannot_be_applied_to_the_shipped_flow():
assert domain.map_x is not None and domain.map_y is not None
rows, columns = domain.shape_hw
source_rows, source_columns = domain.source_hw
assert (rows, columns) == (300, 280) and (source_rows, source_columns) == (288, 512)
assert (rows, columns) == (300, 280)
scale = domain.source_scale
assert (source_rows, source_columns) == (round(720 * scale), round(1280 * scale))
# Bounded by the source, not by the domain: that is what makes them source pixels.
assert 0.0 <= float(domain.map_x[domain.map_x >= 0].max()) <= source_columns - 1
assert 0.0 <= float(domain.map_y[domain.map_y >= 0].max()) <= source_rows - 1
# The values actually present are what decide the two halves of the mistake, not the declared
# size of the source frame: x reaches past the last column of the 280-wide field (a remap would
# read out of range and crash), while y never leaves the 300 rows (a remap would read valid but
# wrong rows, silently). The old form of this assertion accepted ``source_rows <= rows`` as a
# proxy for the y half, which held at ``source_scale`` 0.4 (288 <= 300) but not at 0.42
# (302 > 300) — even though the y values never exceed 284 either way.
assert float(domain.map_x.max()) > columns - 1, (
"x would index past the last column of a 280-wide flow field"
)
assert float(domain.map_y.max()) > rows - 1 or source_rows <= rows, (
assert float(domain.map_y.max()) < rows - 1, (
"y stays inside the 300-row field: the y half of the mistake is silent"
)