Split [PATTERNS] in/out
This commit is contained in:
@@ -97,6 +97,45 @@ def delete_pattern(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
# [EPA2][IN][OUT]
|
||||
# ;desc
|
||||
# id mult1 mult2 .....
|
||||
#--------------------------------------------------------------
|
||||
def inp_in_pattern(section: list[str]) -> ChangeSet:
|
||||
descs = {}
|
||||
patterns: dict[str, list[float]] = {}
|
||||
|
||||
count = len(section)
|
||||
for i in range(0, count):
|
||||
if section[i].startswith(';'):
|
||||
# this is description
|
||||
next = i + 1
|
||||
if next < count and section[next].startswith(';') == False:
|
||||
next_tokens = section[next].split()
|
||||
descs[next_tokens[0]] = section[i].removeprefix(';')
|
||||
continue
|
||||
|
||||
tokens = section[i].split()
|
||||
if tokens[0] not in patterns:
|
||||
patterns[tokens[0]] = []
|
||||
for token in tokens[1:]:
|
||||
patterns[tokens[0]].append(float(token))
|
||||
|
||||
cs = ChangeSet()
|
||||
for id, factors in patterns.items():
|
||||
cs.append(g_add_prefix | {'type': 'pattern', 'id' : id, 'factors' : factors})
|
||||
|
||||
#print(descs)
|
||||
return cs
|
||||
|
||||
|
||||
def inp_out_pattern(name: str) -> list[str]:
|
||||
lines = []
|
||||
objs = read_all(name, f"select * from patterns order by _order")
|
||||
for obj in objs:
|
||||
id = obj['id']
|
||||
factor = obj['factor']
|
||||
lines.append(f'{id} {factor}')
|
||||
return lines
|
||||
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# [EPA3][IN][OUT]
|
||||
# id FIXED (interval)
|
||||
@@ -104,7 +143,7 @@ def delete_pattern(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
# id VARIABLE
|
||||
# id time1 factor1 time2 factor2 ...
|
||||
#--------------------------------------------------------------
|
||||
def inp_in_pattern(section: list[str]) -> ChangeSet:
|
||||
def inp_in_pattern_v3(section: list[str]) -> ChangeSet:
|
||||
descs = {}
|
||||
patterns: dict[str, list[float]] = {}
|
||||
|
||||
@@ -146,11 +185,5 @@ def inp_in_pattern(section: list[str]) -> ChangeSet:
|
||||
return cs
|
||||
|
||||
|
||||
def inp_out_pattern(name: str) -> list[str]:
|
||||
lines = []
|
||||
objs = read_all(name, f"select * from patterns order by _order")
|
||||
for obj in objs:
|
||||
id = obj['id']
|
||||
factor = obj['factor']
|
||||
lines.append(f'{id} {factor}')
|
||||
return lines
|
||||
def inp_out_pattern_v3(name: str) -> list[str]:
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user