首页 > 解决方案 > PyGears 重新排序位

问题描述

我想在将位发送到另一个模块之前对其进行重新排序。我想制作需要 2 个输入像素和重量的齿轮,并且称为重新排序的输出应该是:

reordered[0] = {pixel[0],weight[0]}
reordered[1] = {pixel[1],weight[1]}

下面是一张解释所需装备的图片: 在此处输入图像描述

标签: pygears

解决方案


我假设像素和权重都作为一个界面出现,因此我将其分组。该模块应如下所示:

@datagear 
def reorder( din: Queue[Tuple['pixel', 'weight']] ) -> Array[Queue[Tuple['pixel.data', 'weight.data']], 3]: 
    pixel  = din.data[0] 
    weight = din.data[1] 

    return ( 
        ((pixel[0], weight[0]), din.eot), 
        ((pixel[1], weight[1]), din.eot), 
        ((pixel[2], weight[2]), din.eot), 
    )

Datagear 通常用于处理数据并对其进行重新排序。

但请记住,如果 Pixel 和 Weight 是两个接口,则会为这两个接口的同步生成额外的逻辑。


推荐阅读