sf.engine.Result

class Result(samples)[source]

Bases: object

Result of a quantum computation.

Represents the results of the execution of a quantum program returned by the LocalEngine.run() method.

The returned Result object provides several useful properties for accessing the results of your program execution:

  • results.state: The quantum state object contains details and methods for manipulation of the final circuit state. Not available for remote backends. See States for more information regarding available state methods.

  • results.samples: Measurement samples from any measurements performed.

Example:

The following examples run an existing Strawberry Fields quantum Program on the Gaussian engine to get a results object.

Using this results object, the measurement samples can be returned, as well as quantum state information.

>>> eng = sf.Engine("gaussian")
>>> results = eng.run(prog)
>>> print(results)
Result: 3 subsystems
    state: <GaussianState: num_modes=3, pure=True, hbar=2>
    samples: [0, 0, 0]
>>> results.samples
[0, 0, 0]
>>> results.state.is_pure()
True

Note

Only local simulators will return a state object. Remote simulators and hardware backends will return measurement samples (Result.samples), but the return value of Result.state will be None.

samples

Measurement samples.

state

The quantum state object.

samples

Measurement samples.

Returned measurement samples will have shape (modes,). If multiple shots are requested during execution, the returned measurement samples will instead have shape (shots, modes).

Returns

measurement samples returned from program execution

Return type

array[array[float, int]]

state

The quantum state object.

The quantum state object contains details and methods for manipulation of the final circuit state.

See States for more information regarding available state methods.

Note

Only local simulators will return a state object. Remote simulators and hardware backends will return measurement samples (Result.samples), but the return value of Result.state will be None.

Returns

quantum state returned from program execution

Return type

BaseState