Blackbird I/O

This module contains functions for loading and saving Strawberry Fields Program objects from/to Blackbird scripts.

Summary

to_blackbird(prog[, version]) Convert a Strawberry Fields Program to a Blackbird Program.
to_program(bb) Convert a Blackbird Program to a Strawberry Fields Program.
save(f, prog) Saves a quantum program to a Blackbird .xbb file.
load(f) Load a quantum program from a Blackbird .xbb file.

Code details

strawberryfields.io.to_blackbird(prog, version='1.0')[source]

Convert a Strawberry Fields Program to a Blackbird Program.

Parameters:
  • prog (Program) – the Strawberry Fields program
  • version (str) – Blackbird script version number
Returns:

Return type:

blackbird.BlackbirdProgram

strawberryfields.io.to_program(bb)[source]

Convert a Blackbird Program to a Strawberry Fields Program.

Parameters:bb (blackbird.BlackbirdProgram) – the input Blackbird program object
Returns:corresponding SF program
Return type:Program
strawberryfields.io.save(f, prog)[source]

Saves a quantum program to a Blackbird .xbb file.

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
strawberryfields.io.load(f)[source]

Load a quantum program from a Blackbird .xbb file.

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.
Returns:Strawberry Fields program
Return type:prog (Program)