Skip to content

Commit 5623792

Browse files
committed
Add check for equal count of pulse types & lengths
1 parent 06e75e4 commit 5623792

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

picode.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,17 @@ def picode_parse(picode:str):
149149

150150
# Add param1 to result dict
151151
result["c"] = pulses_type
152-
153-
# All checks OK
154-
return result
152+
153+
# Check for uniq pulses_type count equal to pulses_length count
154+
if len(set(pulses_type)) > len(pulses_length):
155+
# error: uniq pulses_type > pulses_length
156+
return
157+
elif len(set(pulses_type)) < len(pulses_length):
158+
# error: pulses_length > uniq pulses_type
159+
return
160+
else:
161+
# All checks OK
162+
return result
155163
else:
156164
# error: invalid params number (;)
157165
return
@@ -197,9 +205,12 @@ def picode_pulselist(picode:dict):
197205
if isinstance(picode["c"], list) and isinstance(picode["p"], list):
198206
# Pulses loop
199207
for pulse_type in picode["c"]:
200-
# Add pulse value to pulse list
201-
pulse_list.append((picode["p"][pulse_type]))
202-
208+
try:
209+
# Add pulse value to pulse list
210+
pulse_list.append((picode["p"][pulse_type]))
211+
except:
212+
# error: list index out of range
213+
return
203214
# All checks OK
204215
return pulse_list
205216
else:

0 commit comments

Comments
 (0)