holy fuking shit

This commit is contained in:
Horldsence
2026-09-12 01:56:34 +08:00
parent 36f354736c
commit d975309a81
83 changed files with 2748 additions and 896 deletions
+14 -14
View File
@@ -90,7 +90,7 @@ class LayoutTests(unittest.TestCase):
again = env._loop.hrl_observation(env._current_candidates)
self.assertTrue(numpy.array_equal(obs, again))
def test_mask_admits_at_least_one_action_and_aligns_with_candidates(self):
def test_mask_nonempty_and_matches_candidate_slots(self):
env = _env(problem=3)
env.reset(seed=7)
for _ in range(6):
@@ -98,7 +98,7 @@ class LayoutTests(unittest.TestCase):
self.assertTrue(mask.any())
slots = {cand.slot for cand in env._current_candidates}
self.assertEqual({int(i) for i in numpy.flatnonzero(mask)}, slots)
obs, _r, term, trunc, _info = env.step(
_obs, _r, term, trunc, _info = env.step(
int(env._loop.heuristic_action(env._current_candidates)))
if term or trunc:
break
@@ -114,7 +114,7 @@ class LayoutTests(unittest.TestCase):
self.assertEqual(FALLBACK_OFFSET, STATION_OFFSET + STATION_SLOTS)
self.assertEqual(N_CANDIDATES - (FALLBACK_OFFSET + FALLBACK_SLOTS), 11)
def test_build_candidates_keeps_clear_17_to_20_and_locate_1_to_4(self):
def test_build_candidates_keeps_clear_and_locate(self):
host = _CandidateHost(detected=[1, 2, 3, 4, 17, 18, 19, 20],
certified=[17, 18, 19, 20])
candidates = host.build_candidates()
@@ -130,7 +130,7 @@ class LayoutTests(unittest.TestCase):
selected = host.candidate_by_slot(candidates, CLEAR_OFFSET + channel - 1)
self.assertEqual((selected.kind, selected.channel), ("clear", channel))
def test_build_candidates_fallback_includes_channel_20_within_its_slots(self):
def test_build_candidates_fallback_covers_slots(self):
channels = list(range(17, 21))
host = _CandidateHost(detected=channels, blocked=channels)
candidates = host.build_candidates()
@@ -151,11 +151,11 @@ class LayoutTests(unittest.TestCase):
class HeuristicLoopTests(unittest.TestCase):
def test_q3_full_episode_clears_all_sources(self):
env = _env(problem=3, stage_index=3, max_episode_steps=500)
obs, _ = env.reset(seed=11)
_, _ = env.reset(seed=11)
steps = 0
while True:
action = env._loop.heuristic_action(env._current_candidates)
obs, r, term, trunc, info = env.step(action)
_, _, term, trunc, info = env.step(action)
steps += 1
if term or trunc:
break
@@ -170,7 +170,7 @@ class HeuristicLoopTests(unittest.TestCase):
env.reset(seed=21)
while True:
action = env._loop.heuristic_action(env._current_candidates)
obs, r, term, trunc, info = env.step(action)
_, _, term, trunc, info = env.step(action)
if term or trunc:
break
self.assertTrue(term)
@@ -185,8 +185,8 @@ class HeuristicLoopTests(unittest.TestCase):
reward_cfg = env.reward
for _ in range(8):
action = env._loop.heuristic_action(env._current_candidates)
virtual_before = env._client.state.virtual_time_s
obs, r, term, trunc, info = env.step(action)
_virtual_before = env._client.state.virtual_time_s
_, r, term, trunc, info = env.step(action)
outcome = env._last_outcome
if outcome.invalid:
self.assertAlmostEqual(r, -reward_cfg.invalid, places=6)
@@ -206,13 +206,13 @@ class HeuristicLoopTests(unittest.TestCase):
if term or trunc:
break
def test_invalid_action_penalized_without_simulator_interaction(self):
def test_invalid_action_penalized_without_sim_call(self):
env = _env(problem=3, stage_index=0, max_episode_steps=50)
env.reset(seed=3)
mask = env.action_masks()
invalid_action = int(numpy.argmin(mask))
virtual_before = env._client.state.virtual_time_s
obs, r, term, trunc, info = env.step(invalid_action)
_, r, _, _, _ = env.step(invalid_action)
self.assertAlmostEqual(r, -env.reward.invalid, places=6)
self.assertAlmostEqual(env._client.state.virtual_time_s,
virtual_before, places=6)
@@ -228,7 +228,7 @@ class LowLevelTests(unittest.TestCase):
goal = tuple(info["goal"])
total = 0
for _ in range(60):
obs, r, term, trunc, info = env.step(env.expert_action())
obs, _, term, trunc, _ = env.step(env.expert_action())
total += 1
if term or trunc:
break
@@ -237,7 +237,7 @@ class LowLevelTests(unittest.TestCase):
efficiency = straight / (total * env.step_m)
self.assertGreater(efficiency, 0.7, "专家路径效率应接近直线")
def test_executor_straightline_is_goal_only_and_policy_path_snaps(self):
def test_executor_straightline_is_goal_only(self):
executor = LowLevelExecutor(policy=None)
self.assertEqual(executor.roll((0.0, 0.0), (500.0, 200.0)),
[(500.0, 200.0)])
@@ -257,7 +257,7 @@ class CurriculumTests(unittest.TestCase):
self.assertLessEqual(prev.bearing_error_half_deg,
nxt.bearing_error_half_deg)
def test_training_config_defaults_to_production_fidelity(self):
def test_training_config_defaults_to_production(self):
config = training_config(CONFIG, STAGES[3])
self.assertEqual(config.field.channel_max, 20)
self.assertEqual(config.field.bearing_error_half_deg, 1.0)