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 187 forks source link

Deep copy from `Program.compile()` #688

Closed thisac closed 2 years ago

thisac commented 2 years ago

Context: The compiler create a linked copy of the program by calling Program._linked_copy(), which retains the same regrefs. Since the copy is shallow, it also keeps the same TDM parameters in a TDM program. These parameters are updated by the compiler and thus changed in both the compiled program and the initial program, while the circuit is only changed in the compiled program.

Description of the Change:

Benefits: The compiler actually returns a copy of the program without changing anything in the original program.

Possible Drawbacks: None

Related GitHub Issues: None

codecov[bot] commented 2 years ago

Codecov Report

Merging #688 (d6665b6) into master (efdf123) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #688   +/-   ##
=======================================
  Coverage   98.69%   98.69%           
=======================================
  Files          75       75           
  Lines        9209     9212    +3     
=======================================
+ Hits         9089     9092    +3     
  Misses        120      120           
Impacted Files Coverage Δ
strawberryfields/program.py 100.00% <100.00%> (ø)

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 efdf123...d6665b6. Read the comment docs.