Skip to content

Commit 6847a25

Browse files
committed
fix typo which broke some symbolic formulas accessing previously recorded data like "Y{0}" (thanks Dave for the report!)
1 parent 4fdb284 commit 6847a25

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/artisanlib/canvas.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -6528,7 +6528,7 @@ def eval_math_expression(self,mathexpression:str, t:float, equeditnumber:Optiona
65286528
#Example1 "Y2[-7]" = "Y20070" Example2 "Y2[+9]" = "Y21191"
65296529
mathexpression = evaltimeexpression.join((mathexpression[:i],mathexpression[i+offset+6:]))
65306530
#direct index access: e.g. "Y2{CHARGE}" or "Y2{12}"
6531-
elif i+5+offset < len(mathexpression) and mathexpression[i+offset+2] == '{' and mathexpression.find('}',i+offset+3) > -1:
6531+
elif i+4+offset < mlen and mathexpression[i+offset+2] == '{' and mathexpression.find('}',i+offset+3) > -1:
65326532
end_idx = mathexpression.index('}',i+offset+3)
65336533
body = mathexpression[i+3:end_idx]
65346534
val = -1
@@ -6602,7 +6602,7 @@ def eval_math_expression(self,mathexpression:str, t:float, equeditnumber:Optiona
66026602
if mathexpression[i+k+1].isdigit():
66036603
nint = int(mathexpression[i+k+1]) #Rnumber int
66046604
#check for TIMESHIFT 0-9 (one digit). Example: "R1[-2]" or RB1[-2]
6605-
if i+k+5 < len(mathexpression) and mathexpression[i+k+2] == '[':
6605+
if i+k+5 < mlen and mathexpression[i+k+2] == '[':
66066606
Yshiftval = int(mathexpression[i+k+4])
66076607
sign = mathexpression[i+k+3]
66086608

@@ -6642,7 +6642,7 @@ def eval_math_expression(self,mathexpression:str, t:float, equeditnumber:Optiona
66426642
mathexpression = evaltimeexpression.join((mathexpression[:i],mathexpression[i+k+6:]))
66436643

66446644
#direct index access: e.g. "R2{CHARGE}" or "R2{12}"
6645-
elif i+k+5 < len(mathexpression) and mathexpression[i+k+2] == '{' and mathexpression.find('}',i+k+3) > -1:
6645+
elif i+k+5 < mlen and mathexpression[i+k+2] == '{' and mathexpression.find('}',i+k+3) > -1:
66466646
end_idx = mathexpression.index('}',i+k+3)
66476647
body = mathexpression[i+k+3:end_idx]
66486648
val = -1
@@ -6757,7 +6757,7 @@ def eval_math_expression(self,mathexpression:str, t:float, equeditnumber:Optiona
67576757
else:
67586758
timex = self.abs_timeB
67596759
seconddigitstr = ''
6760-
if i+4 < len(mathexpression) and mathexpression[i+1] == '[':
6760+
if i+4 < mlen and mathexpression[i+1] == '[':
67616761
Yshiftval = int(mathexpression[i+3])
67626762
sign = mathexpression[i+2]
67636763

@@ -6775,7 +6775,7 @@ def eval_math_expression(self,mathexpression:str, t:float, equeditnumber:Optiona
67756775
timeshiftexpressionsvalues.append(val)
67766776
mathexpression = evaltimeexpression.join((mathexpression[:i],mathexpression[i+5:]))
67776777
#direct index access: e.g. "t{CHARGE}" or "t{12}"
6778-
elif i+3 < len(mathexpression) and mathexpression[i+1] == '{' and mathexpression.find('}',i+2) > -1:
6778+
elif i+3 < mlen and mathexpression[i+1] == '{' and mathexpression.find('}',i+2) > -1:
67796779
end_idx = mathexpression.index('}',i+2)
67806780
body = mathexpression[i+2:end_idx]
67816781
if mathexpression[i]=='b':
@@ -6803,7 +6803,7 @@ def eval_math_expression(self,mathexpression:str, t:float, equeditnumber:Optiona
68036803
elif mathexpression[i] == 'P' and i+1 < mlen and mathexpression[i+1].isdigit(): #check for out of range
68046804
nint = int(mathexpression[i+1]) #Ynumber int
68056805
#check for TIMESHIFT 0-9 (one digit). Example: "Y1[-2]"
6806-
if i+5 < len(mathexpression) and mathexpression[i+2] == '[' and mathexpression[i+5] == ']':
6806+
if i+5 < mlen and mathexpression[i+2] == '[' and mathexpression[i+5] == ']':
68076807
Yshiftval = int(mathexpression[i+4])
68086808
sign = mathexpression[i+3]
68096809
evaltimeexpression = ''.join(('P',mathexpression[i+1],'1'*2,mathexpression[i+4],'1'))
@@ -6827,7 +6827,7 @@ def eval_math_expression(self,mathexpression:str, t:float, equeditnumber:Optiona
68276827
if mathexpression[i+1].isdigit():
68286828
nint = int(mathexpression[i+1]) #Bnumber int
68296829
#check for TIMESHIFT 0-9 (one digit). Example: "B1[-2]"
6830-
if i+5 < len(mathexpression) and mathexpression[i+2] == '[':
6830+
if i+5 < mlen and mathexpression[i+2] == '[':
68316831
Yshiftval = int(mathexpression[i+4])
68326832
sign = mathexpression[i+3]
68336833

@@ -6877,7 +6877,7 @@ def eval_math_expression(self,mathexpression:str, t:float, equeditnumber:Optiona
68776877
timeshiftexpressionsvalues.append(val)
68786878
mathexpression = evaltimeexpression.join((mathexpression[:i],mathexpression[i+6:]))
68796879
#direct index access: e.g. "B2{CHARGE}" or "B2{12}"
6880-
elif i+5 < len(mathexpression) and mathexpression[i+2] == '{' and mathexpression.find('}',i+3) > -1:
6880+
elif i+5 < mlen and mathexpression[i+2] == '{' and mathexpression.find('}',i+3) > -1:
68816881
end_idx = mathexpression.index('}',i+3)
68826882
body = mathexpression[i+3:end_idx]
68836883
val = -1

0 commit comments

Comments
 (0)