Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for mypy. #84

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions pytket/extensions/braket/backends/braket.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,13 @@ def __init__(
# load config
config = BraketConfig.from_default_config_file()
if s3_bucket is None:
s3_bucket = config.s3_bucket
s3_bucket = config.s3_bucket # type: ignore
if s3_folder is None:
s3_folder = config.s3_folder
s3_folder = config.s3_folder # type: ignore
if device_type is None:
device_type = config.device_type
device_type = config.device_type # type: ignore
if provider is None:
provider = config.provider
provider = config.provider # type: ignore

# set defaults if not overridden
if device_type is None:
Expand Down Expand Up @@ -627,11 +627,12 @@ def default_compilation_pass(self, optimisation_level: int = 1) -> BasePass:
and (not self._requires_all_qubits_measured)
):
arch = self.backend_info.architecture
assert isinstance(arch, Architecture)
passes.append(
CXMappingPass(
arch,
NoiseAwarePlacement(
arch, **get_avg_characterisation(self.characterisation)
arch, **get_avg_characterisation(self.characterisation) # type: ignore
),
directed_cx=False,
delay_measures=True,
Expand Down Expand Up @@ -994,7 +995,7 @@ def _get_variance(
res = task.result()
return res.get_value_by_result_type(restype) # type: ignore

def get_pauli_expectation_value(
def get_pauli_expectation_value( # type: ignore
self,
state_circuit: Circuit,
pauli: QubitPauliString,
Expand Down Expand Up @@ -1023,7 +1024,7 @@ def get_pauli_expectation_value(
observable, qbs = _obs_from_qps(state_circuit, pauli)
return self._get_expectation_value(bkcirc, observable, qbs, n_shots, **kwargs)

def get_operator_expectation_value(
def get_operator_expectation_value( # type: ignore
self,
state_circuit: Circuit,
operator: QubitPauliOperator,
Expand Down
8 changes: 4 additions & 4 deletions pytket/extensions/braket/backends/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ def set_braket_config(
for AWS Braket. Can be overridden in backend construction."""
config = BraketConfig.from_default_config_file()
if s3_bucket is not None:
config.s3_bucket = s3_bucket
config.s3_bucket = s3_bucket # type: ignore
if s3_folder is not None:
config.s3_folder = s3_folder
config.s3_folder = s3_folder # type: ignore
if device_type is not None:
config.device_type = device_type
config.device_type = device_type # type: ignore
if provider is not None:
config.provider = provider
config.provider = provider # type: ignore
config.update_default_config_file()
2 changes: 2 additions & 0 deletions tests/backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import numpy as np
import pytest
from pytket.extensions.braket import BraketBackend
from pytket.architecture import Architecture
from pytket.circuit import Circuit, OpType, Qubit, Bit # type: ignore
from pytket.pauli import Pauli, QubitPauliString # type: ignore
from pytket.utils.expectations import (
Expand Down Expand Up @@ -159,6 +160,7 @@ def test_ionq(authenticated_braket_backend: BraketBackend) -> None:

# Device is fully connected
arch = b.backend_info.architecture
assert isinstance(arch, Architecture)
n = len(arch.nodes)
assert len(arch.coupling) == n * (n - 1)

Expand Down