sf.io.save

save(f, prog)[source]

Saves a quantum program to a Blackbird .xbb file.

Example:

prog = sf.Program(3)

with prog.context as q:
    ops.Sgate(0.543) | q[1]
    ops.BSgate(0.6, 0.1) | (q[2], q[0])
    ops.MeasureFock() | q

sf.save("program1.xbb", prog)

This will create the following Blackbird file:

>>> f = open("program1.xbb").read()
>>> print(f)
name None
version 1.0

Sgate(0.543, 0.0) | 1
BSgate(0.6, 0.1) | [2, 0]
MeasureFock() | [0, 1, 2]
Parameters
  • f (Union[file, str, pathlib.Path]) – File or filename to which the data is saved. If file is a file-object, then the filename is unchanged. If file is a string or Path, a .xbb extension will be appended to the file name if it does not already have one.

  • prog (Program) – Strawberry Fields program