perf: 优化汇总用户量渲染
保持逐市场阈值和颜色效果不变,同时缩小汇总阶段的计算缓冲区并补全文档说明。
This commit is contained in:
@@ -78,6 +78,38 @@ class UserCountMergeTest(unittest.TestCase):
|
||||
self.assertEqual(metadata["four_g_only_grid_count"], 1)
|
||||
self.assertEqual(metadata["five_g_only_grid_count"], 1)
|
||||
|
||||
def test_local_summary_render_matches_full_canvas_colors(self):
|
||||
records = {}
|
||||
main.merge_user_count_record(records, "a", (24, 27, 24, 27), 20.0, "5G", True)
|
||||
main.merge_user_count_record(records, "b", (28, 31, 28, 31), 10.0, "5G", True)
|
||||
main.merge_user_count_record(records, "c", (32, 35, 32, 35), 5.0, "4G")
|
||||
thresholds = [15.0, 7.5, 2.5]
|
||||
|
||||
full_state = main.build_merged_user_count_state(records, 64, 64)
|
||||
full_mask = full_state["value_weight"] > 0
|
||||
full_values = np.zeros((64, 64), dtype=np.float32)
|
||||
np.divide(
|
||||
full_state["value_sum"],
|
||||
full_state["value_weight"],
|
||||
out=full_values,
|
||||
where=full_mask,
|
||||
)
|
||||
full_ranked, _ = main.ranked_pixel_rgb_for_values_with_thresholds(
|
||||
full_values,
|
||||
full_mask,
|
||||
main.EXCELLENT_COLORS,
|
||||
thresholds,
|
||||
)
|
||||
expected = main.smooth_rgb_inside_mask(full_ranked, full_mask, main.HEATMAP_SMOOTH_RADIUS)
|
||||
|
||||
local = main.render_merged_user_count_records(records, 64, 64, thresholds)
|
||||
actual = np.zeros_like(expected)
|
||||
row_start, row_stop, col_start, col_stop = local["window"]
|
||||
actual[row_start:row_stop, col_start:col_stop] = local["rgb"]
|
||||
|
||||
np.testing.assert_array_equal(actual, expected)
|
||||
self.assertLess(local["data_mask"].size, full_mask.size)
|
||||
|
||||
|
||||
class CompetitorSignalTest(unittest.TestCase):
|
||||
def test_filter_accepts_weak_coverage_or_zero_competitor_samples(self):
|
||||
|
||||
Reference in New Issue
Block a user