change nets list to dictionary

This commit is contained in:
Sam Crow 2023-07-17 15:36:22 -07:00
parent 7581df2255
commit e15feb2361
1 changed files with 4 additions and 7 deletions

View File

@ -214,12 +214,9 @@ class spice():
def create_nets(self, names_list):
nets = []
for name in names_list:
try:
i = self.nets.index(name)
nets.append(self.nets[i])
except ValueError:
net = net_spice(name)
self.nets.append(net)
# setdefault adds to the dict if it doesn't find the net in it already
# then it returns the net it found or created, a net_spice object
net = self.nets.setdefault(name, net_spice(name))
nets.append(net)
return nets