[英]How to iterate through a nested dictionary into a Schemdraw circuit
我正在尝试使用 schemdraw 将嵌套字典迭代到集成电路中,但这些值在最终绘图中相互重叠,而不是在集成电路上创建新条目。 我想我可能需要多一层迭代,但不确定应该是什么。 任何帮助表示赞赏!
这是我正在使用的:
import schemdraw
import schemdraw.elements.intcircuits as eInt
dict1 = {'channel 1':
{'source_name': '1',
},
'channel 2':
{'source_name': '2',
}}
with schemdraw.Drawing(file='/Users/Desktop/circuitdrawing.png') as d:
for channel, info in dict1.items():
if channel != None:
for channel, info in dict1.items(): #might need another level of iteration here?
d += eInt.Ic(pins=[eInt.IcPin(name=(channel), pin=(info['source_name']), side='left')],
edgepadW = 2,
pinspacing = 1).label('console 1', 'top', fontsize=12)
else:
continue
这是代码的输出:电路图
通过向 pin 信息添加一个额外的 slot 参数来解决,所以它最终看起来像这样:
d += eInt.Ic(pins=[eInt.IcPin(name=(channel), pin=(info['source_name']), side='left'), slot='1/2'],
edgepadW = 2,
pinspacing = 1).label('console 1', 'top', fontsize=12)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.