sf.load

load(f, ir='blackbird')[source]

Load a quantum program from a Blackbird .xbb or an XIR .xir file.

Example:

The following Blackbird file, program1.xbb,

name test_program
version 1.0

Sgate(0.543, 0.0) | 1
BSgate(0.6, 0.1) | [2, 0]
MeasureFock() | [0, 1, 2]

can be imported into Strawberry Fields using the loads function:

>>> sf.loads("program1.xbb", ir="blackbird")
>>> prog.name
'test_program'
>>> prog.num_subsystems
3
>>> prog.print()
Sgate(0.543, 0) | (q[1])
BSgate(0.6, 0.1) | (q[2], q[0])
MeasureFock | (q[0], q[1], q[2])
Parameters
  • f (Union[file, str, pathlib.Path]) – File or filename from which the data is loaded. If file is a string or Path, a value with the .xbb extension is expected.

  • ir (str) – Intermediate representation language to use. Can be either “blackbird” or “xir”.

Returns

Strawberry Fields program

Return type

prog (Program)

Raises

ValueError – if file is not a string, pathlib.Path, or file-like object