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
737 stars 188 forks source link

(un)locking when (un)rolling #703

Closed thisac closed 2 years ago

thisac commented 2 years ago

Context: When a program is compiled it is locked, and no further changes can be made to it. This means that a compiled program cannot be unrolled unless Program.locked = False.

Description of the Change: TDMProgram.unroll and TDMProgram.space_unroll unlock the program before unrolling and, if it was locked before, locks it again.

Benefits: Users no longer have to manually unlock programs before attempting to unroll them.

Possible Drawbacks: None

Related GitHub Issues: None

codecov[bot] commented 2 years ago

Codecov Report

Merging #703 (41fe85d) into master (6441e5d) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #703   +/-   ##
=======================================
  Coverage   98.71%   98.72%           
=======================================
  Files          75       75           
  Lines        9217     9225    +8     
=======================================
+ Hits         9099     9107    +8     
  Misses        118      118           
Impacted Files Coverage Δ
strawberryfields/tdm/tdmprogram.py 99.19% <100.00%> (+0.02%) :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 6441e5d...41fe85d. Read the comment docs.

sduquemesa commented 2 years ago

Great @thisac! Quite simple but very useful. This is just missing a test checking that automatic unlocking/locking does happen when (un)rolling.