def CartesianProduct(dictDeviceParameter):
'''auto XOR用来对有多个参数且参数值可取多个的器件进行笛卡尔积
'''
import copy
productList=[]
productList2=[]
deviceParameter=[]
parameterList=[]
for key in dictDeviceParameter.keys():
parameterList.append(key)
deviceParameter.append(dictDeviceParameter[key])
for key in dictDeviceParameter.keys():
if productList!=[]:
productList2=copy.deepcopy(productList)
for item in productList:
for value in dictDeviceParameter[key]:
resultItem=copy.deepcopy(item)
resultItem.append(value)
productList2.append(resultItem)
productList=copy.deepcopy(productList2)
elif productList==[]:
for value in dictDeviceParameter[key]:
productList.append([value])
# to trim the intermediate variables,
productList2=[]
length=len(dictDeviceParameter.keys())
for item in productList:
if len(item)==length:
productList2.append(item)
return productList2,parameterList