Fix: Floor.mutate(). Geometry drift from repeated calls#6
Fix: Floor.mutate(). Geometry drift from repeated calls#6fcarvajalbrown wants to merge 1 commit intoMLSTRUCT:masterfrom
Conversation
|
Hi. Thanks for pointing this out. Can you,
I think function/class docs should focus on the present, comments on past & present, and TODOs for the future. |
Will fix, regardless, since I see that you have experience and on the same location do you mind if I email you with unrelated questions regarding academia and code please? Thank you in advance Pablo. |
Hi @fcarvajalbrown , sure feel free to email me for these reasons. |
Overview
Floor.mutate()was applying transforms by undoing the previous mutation (reverse angle, inverse scale) and then applying the new one.This approach is not a true inverse — the undo math is order-dependent, and floating-point compound roundings on every call.
The result is that calling
mutate()multiple times on the same floor progressively incorrect geometry, a problem for ML data augmentation pipelines that generate multiple crops at different angles.Changes
MLStructFP/db/__init__.pyMLStructFP/db/_floor.py_original_points: Optional[Dict]field toFloor, initialized toNonein__init__.mutate()call, the original(x, y)of every point across all components is snaps hotted (?) into_original_points, assigned by object identity.self.mutate(-_angle, 1/_sx, 1/_sy, ...)), which was the source of the bug; after testing.Testing
A standalone test file (
test_floor_mutate.py) is available in case for addition to the repository, the results are the following:17 tests, all passing.