Skip to content

Commit

Permalink
fix: pyright issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AthenaCaesura committed Mar 29, 2024
1 parent e189f2e commit d143f05
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
9 changes: 3 additions & 6 deletions src/benchq/algorithms/gsee/qpe_gsee.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import warnings

import numpy as np
from orquestra.integrations.cirq.conversions import (
to_openfermion, # pyright: ignore[reportPrivateImportUsage]
)
from orquestra.quantum.operators import PauliRepresentation
from pyLIQTR.QSP.Hamiltonian import Hamiltonian

from ...algorithms.data_structures import AlgorithmImplementation, ErrorBudget
from ...conversions import openfermion_to_pyliqtr
from ...conversions import SUPPORTED_OPERATORS, get_pyliqtr_operator
from ...problem_embeddings.qsp import get_qsp_program


Expand All @@ -17,9 +13,10 @@ def _n_block_encodings(hamiltonian: Hamiltonian, precision: float) -> int:


def qpe_gsee_algorithm(
hamiltonian: PauliRepresentation, precision: float, failure_tolerance: float
hamiltonian: SUPPORTED_OPERATORS, precision: float, failure_tolerance: float
) -> AlgorithmImplementation:
warnings.warn("This is experimental implementation, use at your own risk.")
hamiltonian = get_pyliqtr_operator(hamiltonian)
n_block_encodings = _n_block_encodings(hamiltonian, precision)
program = get_qsp_program(hamiltonian, n_block_encodings)
error_budget = ErrorBudget.from_even_split(failure_tolerance)
Expand Down
8 changes: 5 additions & 3 deletions src/benchq/visualization_tools/plot_graph_state.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import List

import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import networkx as nx
Expand Down Expand Up @@ -133,7 +135,7 @@ def plot_graph_state(asg, pauli_tracker):
lambda x: x[1]["shape"] == aShape, graph.nodes(data=True)
)
]
colors_for_nodes_with_this_shape = [
colors_for_nodes_with_this_shape: List[mpatches.Patch] = [
color_map[i] for i in nodes_with_this_shape if 0 <= i < len(color_map)
]

Expand Down Expand Up @@ -213,10 +215,10 @@ def plot_graph_state(asg, pauli_tracker):

plt.tight_layout()
# Create a legend
red_patch = plt.Line2D(
red_patch = plt.Line2D( # pyright: ignore[reportPrivateImportUsage]
[0], [0], marker="o", color="w", markerfacecolor="red", markersize=8, label="X"
)
blue_patch = plt.Line2D(
blue_patch = plt.Line2D( # pyright: ignore[reportPrivateImportUsage]
[0], [0], marker="o", color="w", markerfacecolor="blue", markersize=8, label="Z"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
def plot_graph_state_with_measurement_steps(
asg,
measurement_steps,
cmap=plt.cm.rainbow,
cmap=plt.cm.rainbow, # pyright: ignore[reportAttributeAccessIssue]
name="extrapolation_plot",
):
"""Plot a graph state with the measurement steps highlighted in different
Expand Down
3 changes: 2 additions & 1 deletion tests/benchq/compilation/test_rbs_with_pauli_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def check_correctness_for_single_init(
n = len(pdf)

all_bitstrings = [
format(i, f"0{full_circuit.n_qubits}b") for i in range(2**full_circuit.n_qubits)
format(i, f"0{full_circuit.n_qubits}b")
for i in range(2**full_circuit.n_qubits)
]

for i in range(n):
Expand Down

0 comments on commit d143f05

Please sign in to comment.