XanaduAI / strawberryfields

Strawberry Fields is a full-stack Python library for designing, simulating, and optimizing continuous variable (CV) quantum optical circuits.
https://strawberryfields.ai
Apache License 2.0
754 stars 191 forks source link

Fix issue with single parameter list #503

Closed thisac closed 3 years ago

thisac commented 3 years ago

Context: eng.run(prog) crashes when attempting to use a single parameter list in the TDMProgram context.

Description of the Change: A fix is added that changes a single free parameter to a list when only passing a single parameter list to the TDMProgram context.

Benefits:

The following now works:

prog = sf.TDMProgram(2)
eng = sf.Engine("gaussian")

with prog.context([1, 2]) as (p, q):
    ops.Sgate(p[0]) | q[0]
    ops.MeasureHomodyne(p[0]) | q[0]

eng.run(prog)

Possible Drawbacks: None

Related GitHub Issues: None

codecov[bot] commented 3 years ago

Codecov Report

Merging #503 (6d0163a) into master (75e3c26) will increase coverage by 0.01%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #503      +/-   ##
==========================================
+ Coverage   97.85%   97.86%   +0.01%     
==========================================
  Files          70       70              
  Lines        7313     7316       +3     
==========================================
+ Hits         7156     7160       +4     
+ Misses        157      156       -1     
Impacted Files Coverage Δ
strawberryfields/tdm/tdmprogram.py 95.67% <100.00%> (+0.62%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 75e3c26...6d0163a. Read the comment docs.