Skip to content

Task results

QuEraTaskResults

Bases: BaseModel

export_as_probabilities

export_as_probabilities()

converts from shot results to probabilities

Returns:

Name Type Description
TaskProbabilities TaskProbabilities

The task results as probabilties

Source code in src/bloqade/submission/ir/task_results.py
def export_as_probabilities(self) -> TaskProbabilities:
    """converts from shot results to probabilities

    Returns:
        TaskProbabilities: The task results as probabilties
    """
    counts = dict()
    nshots = len(self.shot_outputs)
    for shot_result in self.shot_outputs:
        pre_sequence_str = "".join(str(bit) for bit in shot_result.pre_sequence)

        post_sequence_str = "".join(str(bit) for bit in shot_result.post_sequence)

        configuration = (pre_sequence_str, post_sequence_str)
        # iterative average
        current_count = counts.get(configuration, 0)
        counts[configuration] = current_count + 1

    probabilities = [(config, count / nshots) for config, count in counts.items()]
    return TaskProbabilities(probabilities=probabilities)