What happens when a stream of quality flags is shorter than its samples?
compress consumes data and selectors in step, emitting items with true selectors. It stops when either input ends.
Python example and interpretation
Three records with only two flags leave the third unexamined. An audit should independently verify both the lengths and sample identities.
from itertools import compress
list(compress(['r1','r2','r3'],[True,False]))Result ['r1']
中文
质量标记少于样本时,掩码筛选在哪里停止?
compress 同步读取样本与选择标记,输出标记为真的元素;任一输入耗尽就停止。
Python 算例与适用条件
三条记录只收到了两个标记,第三条会被跳过。严格审核流程应另行检查两份记录数与身份。
from itertools import compress
list(compress(['r1','r2','r3'],[True,False]))结果 ['r1']