SimulationResult¶
- class lightworks.sdk.results.SimulationResult(results: ndarray[Any, dtype[float64 | complex128]], result_type: str, inputs: list[State], outputs: list[State], **kwargs: Any)¶
Stores results data from a given simulation in the emulator. There is then a range of options for displaying the data, or alternatively the data can be accessed directly using the [] operator on the class to select which input and output data is required.
- Parameters:
results (np.ndarray) – The results which are to be stored.
result_type (str) – The type of results which are being stored. This should either be probability, probability_amplitude or counts.
inputs (list) – A list of the inputs used for creation of the results.
outputs (list) – A list of the possible outputs from the results.
- property array: ndarray[Any, dtype[float64 | complex128]]¶
The calculated array of data, where the first dimension corresponds to the inputs and the second dimension to the outputs.
- display_as_dataframe(threshold: float = 1e-12, conv_to_probability: bool = False) DataFrame ¶
Function to display the results of a given simulation in a dataframe format. Either the probability amplitudes of the state, or the actual probabilities can be displayed.
- Parameters:
threshold (float, optional) – Threshold to control at which point value are rounded to zero. If looking for very small amplitudes this may need to be lowered.
conv_to_probability (bool, optional) – In the case that the result is a probability amplitude, setting this to True will convert it into a probability. If it is not a probability amplitude then this setting will have no effect.
- Returns:
- A dataframe with the results and input and output
states as labels.
- Return type:
pd.Dataframe
- map(mapping: Callable[[State, Any], State], *args: Any, **kwargs: Any) SimulationResult ¶
Performs a generic remapping of states based on a provided function.
- plot(conv_to_probability: bool = False, show: bool = True, state_labels: dict[State, str | State] | None = None) tuple[Figure, Axes | ndarray[Any, dtype[Any]]] | None ¶
Create a plot of the data contained in the result. This will either take the form of a heatmap or bar chart, depending on the nature of the data contained in the Result object.
- Parameters:
conv_to_probability (bool, optional) – In the case that the result is a probability amplitude, setting this to True will convert it into a probability.
show (bool, optional) – Can be used to automatically show the created plot with show instead of returning the figure and axes.
state_labels (dict, optional) – Provided a dictionary which can be used to specify alternate labels for each of the states when plotting. The keys of this dictionary should be States and the values should be strings or States.
- print_outputs(rounding: int = 4) None ¶
Print the output results for each input into the system. This is compatible with all possible result types.
- Parameters:
rounding (int, optional) – Set the number of decimal places which each number will be rounded to, defaults to 4.
- property result_type: str¶
Details where the result is a probability or probability amplitude.