Skip to content

Commit

Permalink
fixed a bug in the injection operator#
Browse files Browse the repository at this point in the history
  • Loading branch information
positr0nium committed Feb 27, 2025
1 parent 1f81e8e commit 61d5f20
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/qrisp/misc/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,11 @@ def redirected_qfunction(*args, target=None, **kwargs):
flattened_args.append(target.reg.tracer)

res = eval_jaxpr(transformed_jaspr, [])(*flattened_args)
qs.abs_qc = res[0]

if len(transformed_jaspr.outvars) == 1:
qs.abs_qc = res
else:
qs.abs_qc = res[0]

else:

Expand Down
19 changes: 19 additions & 0 deletions tests/jax_tests/test_injection_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,22 @@ def main(i):

for i in range(2, 6):
assert main(i) == 0

def AND(a, b):
res = QuantumBool()
mcx([a, b], res)
return res

@jaspify
def main():
a = QuantumBool()
b = QuantumBool()

tar = QuantumBool()

(tar << AND)(a,b)

res = measure(tar)
return res

main()

0 comments on commit 61d5f20

Please sign in to comment.