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

Update `examples/teleportation.py` #612

Closed thisac closed 2 years ago

thisac commented 3 years ago

Issue description

The teleportation.py tutorial in the examples folder is very outdated, and uses functionality latest seen in v0.11.0 (e.g. the strawberryfields.utils.scale function). It should either be updated or removed.

It can be found here: https://github.com/XanaduAI/strawberryfields/blob/master/examples/teleportation.py

Source code and tracebacks

Running it with any later versions of SF causes the following error to be raised.

Traceback (most recent call last):
 File "/Users/pmigdal/not_my_repos/strawberryfields/examples/teleportation.py", line 4, in <module>
  from strawberryfields.utils import scale
ImportError: cannot import name 'scale' from 'strawberryfields.utils' (/opt/anaconda3/envs/dwave/lib/python3.9/site-packages/strawberryfields/utils/__init__.py)
josh146 commented 3 years ago

Good catch 😨

gsuarezr commented 3 years ago

it also contains Coherent(1+0.5j) | q[0] which causes ValueError: The arguments of Coherent(r, phi) cannot be complex

newbie here this was actually the first example I tried to run, this error is an easy fix but I also wanted to print the circuit and can't find a way to actually do it, prog.draw_circuit() causes UnsupportedGateException: Unsupported operation Coherent(1, 0) | (q[0]) not printable by circuit builder!