Skip to content

Commit

Permalink
Update utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasc-ubc committed Mar 24, 2024
1 parent 87faff8 commit c5293e3
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions klayout_dot_config/python/SiEPIC/opics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,24 @@ def LUT_reader(filedir: PosixPath, lutfilename: str, lutdata: List[List[str]]):
print(1)

for node in root.iter("association"):
# sample = [[each.attrib["name"], each.text] for each in node.iter("value")]
sample = [[each.attrib["name"], float(each.text) if each.attrib["type"]=='double' else int(each.text) if each.attrib["type"]=='int' else bool(each.text) if each.attrib["type"]=='bool' else each.text] for each in node.iter("value")]

sample = [[each.attrib["name"], each.text] for each in node.iter("value")]
'''
Look-up is not working. returns the last one each time.
Attempt to fix it.. gave up...
sample = [[each.attrib["name"], float(each.text) if each.attrib["type"]=='double' else int(each.text) if each.attrib["type"]=='int' else bool(each.text) if each.attrib["type"]=='bool' else each.text, each.attrib["type"]] for each in node.iter("value")]
# Make sure the two data sets have the same datatypes
for q in lutdata:
w = [r for r in sample if r[0]==q[0]] [0]
if w[2] == 'double':
q[1] = float(q[1])
if w[2] == 'bool':
q[1] = bool(q[1])
if w[2] == 'int':
q[1] = int(q[1])
'''

if sorted(sample[0:-1]) == sorted(lutdata):
break
sparam_file = sample[-1][1].split(";")
Expand Down

0 comments on commit c5293e3

Please sign in to comment.