diff --git a/python/quantum-pecos/src/pecos/engines/cvm/classical.py b/python/quantum-pecos/src/pecos/engines/cvm/classical.py index c4ad9e991..4e4f4f962 100644 --- a/python/quantum-pecos/src/pecos/engines/cvm/classical.py +++ b/python/quantum-pecos/src/pecos/engines/cvm/classical.py @@ -285,7 +285,7 @@ def eval_cop( # Eval assignment # --------------- - expr_eval = recur_eval_op(cop_expr, output, width, shot_id) + expr_eval = recur_eval_op(cop_expr, output, width, shot_id=shot_id) # Assign the final value: # ----------------------- @@ -361,7 +361,6 @@ def eval_condition( a = conditional_expr["a"] b = conditional_expr["b"] op = conditional_expr["op"] - if isinstance(a, str): a = output[a] # str -> BinArray elif isinstance(a, tuple | list) and len(a) == 2: diff --git a/python/quantum-pecos/src/pecos/engines/hybrid_engine_old.py b/python/quantum-pecos/src/pecos/engines/hybrid_engine_old.py index 87cd1d9b1..28016cdbb 100644 --- a/python/quantum-pecos/src/pecos/engines/hybrid_engine_old.py +++ b/python/quantum-pecos/src/pecos/engines/hybrid_engine_old.py @@ -129,6 +129,7 @@ def run( Tuple of final simulator state and output dictionary. """ output = set_output(state, circuit, output_spec, output) + output["JOB_shotnum"] = shot_id output_export = {} self.circuit = circuit diff --git a/python/tests/pecos/regression/test_qasm/regression_qasm/RNGnum_jobvar_h5.qasm b/python/tests/pecos/regression/test_qasm/regression_qasm/RNGnum_jobvar_h5.qasm index 386253c88..c4d66059c 100644 --- a/python/tests/pecos/regression/test_qasm/regression_qasm/RNGnum_jobvar_h5.qasm +++ b/python/tests/pecos/regression/test_qasm/regression_qasm/RNGnum_jobvar_h5.qasm @@ -16,6 +16,10 @@ RNGindex(JOB_shotnum); h q; hgates1[0] = 1; +if (JOB_shotnum == 2) h q; +if (JOB_shotnum == 4) h q; +cond1 = JOB_shotnum + JOB_shotnum + 10; +if (cond1 == 4) h q; cond1 = RNGnum(); if (cond1[0] != 0) h q; diff --git a/python/tests/pecos/regression/test_qasm/regression_qasm/RNGnum_mod_h5.qasm b/python/tests/pecos/regression/test_qasm/regression_qasm/RNGnum_mod_h5.qasm new file mode 100644 index 000000000..4a45aae2a --- /dev/null +++ b/python/tests/pecos/regression/test_qasm/regression_qasm/RNGnum_mod_h5.qasm @@ -0,0 +1,35 @@ +OPENQASM 2.0; +include "qelib1.inc"; +qreg q[5]; +creg c[5]; + +creg cond1[32]; +creg hgates1[4]; + +///////////////////////////////////////////// +// Test RNG functions with jobvar index +///////////////////////////////////////////// + +RNGseed(1000); +RNGbound(16); +RNGindex(JOB_shotnum); + +h q; +hgates1[0] = 1; + +cond1 = RNGnum(); +cond1 = cond1 % 7; +if (cond1[0] != 0) h q; +if (cond1[0] != 0) hgates1[1] = 1; + +cond1 = RNGnum(); +cond1 = cond1 % 7; +if (cond1[1] != 0) h q; +if (cond1[1] != 0) hgates1[2] = 1; + +cond1 = RNGnum(); +cond1 = cond1 % 7; +if (cond1[3] != 0) h q; +if (cond1[3] != 0) hgates1[3] = 1; + +measure q->c;