pygears - PyGears 重新排序位
问题描述
我想在将位发送到另一个模块之前对其进行重新排序。我想制作需要 2 个输入像素和重量的齿轮,并且称为重新排序的输出应该是:
reordered[0] = {pixel[0],weight[0]}
reordered[1] = {pixel[1],weight[1]}
解决方案
我假设像素和权重都作为一个界面出现,因此我将其分组。该模块应如下所示:
@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 是两个接口,则会为这两个接口的同步生成额外的逻辑。
推荐阅读
- c - MacOS 上 hexdump 的奇怪行为
- google-colaboratory - 操作系统错误 errno 107 传输端未连接 --> 使用 google colab
- python - venv在ansible中将系统范围的pip包安装到venv虚拟环境中
- powershell - PowerShell Invoke-Webrequest 登录失败
- c# - 迭代深化深度优先搜索找不到带有 8 个谜题的目标状态
- python-3.x - 序列化 python 元类的实例
- javascript - 如何让函数识别我点击的 div?
- javascript - 使用选框 js 附加时重新启动的问题
- git - 如何编辑 gitconfig 文件?
- javascript - 为每 X 行重复带有命名列的 CSS 网格布局