diff --git a/release/testdata/gen_testdata.py b/release/testdata/gen_testdata.py index 4ae343a..41bdcdf 100644 --- a/release/testdata/gen_testdata.py +++ b/release/testdata/gen_testdata.py @@ -762,9 +762,16 @@ def build_project_data(rng, cfg, words, m_idx, bid_local=True): nrm_lo, nrm_hi = int(cfg["norm_lo"]), max(int(cfg["norm_lo"]), int(cfg["norm_hi"])) res_lo, res_hi = int(cfg["res_lo"]), max(int(cfg["res_lo"]), int(cfg["res_hi"])) _u = {} # 真实库同 code 跨批次重复,lme_lib 有 - for it in words.lmes: # (batch_id, code) 唯一约束 → 先去重再抽样 + for it in words.lmes: # (batch_id, code) 唯一约束 → 先按 code 去重 _u.setdefault(it[0], it) - _uniq = list(_u.values()) + _seen = set() # lmes 还有 (batch_id, x_hash_exact) 唯一约束: + _uniq = [] # 不同 code 的同名同规格同单位也要去重 + for it in _u.values(): + k = md5(it[1], it[2], it[3]) # 与落库 x_hash_exact 同口径 + if k in _seen: + continue + _seen.add(k) + _uniq.append(it) lme_pool = rng.sample(_uniq, min(len(_uniq), rng.randint(260, 520))) lme_by_kind = {1: [], 2: [], 3: []} for it in lme_pool: