def main():
    value_map = {
        (qubit.row, qubit.col): np.random.random() for qubit in cirq.google.Bristlecone.qubits
    }

    heatmap = cirq.Heatmap(value_map)
    heatmap.plot()
Example #2
0
    def heatmap(self, key: str) -> cirq.Heatmap:
        """Return a heatmap for metrics that target single qubits.

        Args:
            key: The metric key to return a heatmap for.

        Returns:
            A `cirq.Heatmap` for the metric.

        Raises:
            ValueError: If the heatmap is not for one/two qubits or the metric
                values are not single floats.
        """
        metrics = self[key]
        if not all(len(k) == 1 for k in metrics.values()):
            raise ValueError(
                'Heatmaps are only supported if all values in a metric are single metric values.'
                + f'{key} has metric values {metrics.values()}')
        value_map = {
            self.key_to_qubits(k): self.value_to_float(v)
            for k, v in metrics.items()
        }
        if all(len(k) == 1 for k in value_map.keys()):
            return cirq.Heatmap(value_map, title=key.replace('_', ' ').title())
        elif all(len(k) == 2 for k in value_map.keys()):
            return cirq.TwoQubitInteractionHeatmap(value_map,
                                                   title=key.replace(
                                                       '_', ' ').title())
        raise ValueError(
            'Heatmaps are only supported if all the targets in a metric are one or two qubits.'
            + f'{key} has target qubits {value_map.keys()}')
def main():
    value_map = {(qubit.row, qubit.col): np.random.random()
                 for qubit in cirq.google.known_devices.Bristlecone.qubits}

    heatmap = cirq.Heatmap(value_map)
    fig, ax = plt.subplots(figsize=(9, 9))
    heatmap.plot(ax)
    fig.show(warn=False)
Example #4
0
def single_qubit_heatmap():
    """Demo of cirq.Heatmap.
    Demonstrates how cirq.Heatmap can be used to generate a heatmap of the qubit fidelities.
    """
    value_map = {(qubit,): np.random.random() for qubit in cirq_google.Sycamore.metadata.qubit_set}

    heatmap = cirq.Heatmap(value_map)
    # This is going to produce an image similar to examples/single_qubit_heatmap_example.png
    heatmap.plot()
Example #5
0
def single_qubit_heatmap():
    """Demo of cirq.Heatmap.
    Demonstrates how cirq.Heatmap can be used to generate a heatmap of the qubit fidelities.
    """
    value_map = {(qubit,): np.random.random() for qubit in cirq.google.Bristlecone.qubits}

    heatmap = cirq.Heatmap(value_map)
    file_path = "examples/single_qubit_heatmap_example.png"
    fig, _ = heatmap.plot()
    fig.figure.savefig(file_path)