ModelTranslator: 新增 pick_best_candidate——过门且岛数最少者择优
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
f0046ea64d
commit
788122b271
@@ -103,5 +103,34 @@ class TestUvpmModeLabel(unittest.TestCase):
|
||||
self.assertEqual(bd.uvpm_mode_label("smart_fallback", False), "smart_fallback")
|
||||
|
||||
|
||||
class TestPickBestCandidate(unittest.TestCase):
|
||||
def _c(self, flipped, overlap, islands, angle):
|
||||
return {"flipped": flipped, "overlap": overlap,
|
||||
"islands": islands, "angle": angle}
|
||||
|
||||
def test_none_when_empty(self):
|
||||
self.assertIsNone(bd.pick_best_candidate([]))
|
||||
|
||||
def test_none_when_no_candidate_passes_gate(self):
|
||||
cands = [self._c(0.30, 0.50, 100, 66), self._c(0.20, 0.40, 200, 45)]
|
||||
self.assertIsNone(bd.pick_best_candidate(cands))
|
||||
|
||||
def test_picks_only_passing(self):
|
||||
cands = [self._c(0.30, 0.50, 50, 66), self._c(0.00, 0.00, 300, 45)]
|
||||
best = bd.pick_best_candidate(cands)
|
||||
self.assertEqual(best["angle"], 45)
|
||||
|
||||
def test_picks_fewest_islands_among_passing(self):
|
||||
cands = [self._c(0.00, 0.00, 120, 55), self._c(0.01, 0.02, 90, 45),
|
||||
self._c(0.00, 0.00, 300, 35)]
|
||||
best = bd.pick_best_candidate(cands)
|
||||
self.assertEqual(best["islands"], 90)
|
||||
|
||||
def test_overlap_none_treated_as_pass(self):
|
||||
cands = [self._c(0.01, None, 42, 66)]
|
||||
best = bd.pick_best_candidate(cands)
|
||||
self.assertEqual(best["islands"], 42)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user