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 bug in Dgate, Coherent, and DisplacedSqueezed #507

Closed trbromley closed 3 years ago

trbromley commented 3 years ago

This PR fixes a bug in Dgate, Coherent, and DisplacedSqueezed where TensorFlow tensors raise an error if fed with an extra dimension due to batching.

codecov[bot] commented 3 years ago

Codecov Report

Merging #507 (2b2c5dd) into master (b75b398) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #507   +/-   ##
=======================================
  Coverage   98.03%   98.03%           
=======================================
  Files          71       71           
  Lines        7486     7489    +3     
=======================================
+ Hits         7339     7342    +3     
  Misses        147      147           
Impacted Files Coverage Δ
strawberryfields/ops.py 98.85% <100.00%> (+<0.01%) :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 b75b398...2b2c5dd. Read the comment docs.

co9olguy commented 3 years ago

Should we test/fix those ops in this PR then?

trbromley commented 3 years ago

Thanks @co9olguy, I have added checks for the other gates @josh146 mentioned: daef1c59941946a8d2d23733b66b5e1ae2b04248. I also can't see any other gates where this issue may occur.

trbromley commented 3 years ago

The approach has been updated due to some issues with failing tests in Python 3.6 :thinking: Should be good to merge now.