Skip to content

Commit

Permalink
Lint examples and test folders
Browse files Browse the repository at this point in the history
  • Loading branch information
rmshaffer committed Dec 3, 2024
1 parent 4ee727c commit 589b392
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 57 deletions.
9 changes: 5 additions & 4 deletions examples/1_Getting_started_with_AutoQASM.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
"source": [
"# general imports\n",
"from collections import Counter\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# AWS imports: Import Braket SDK modules\n",
"from braket.devices import LocalSimulator\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# AutoQASM imports\n",
"import autoqasm as aq\n",
"from autoqasm.instructions import measure, h, cnot"
"from autoqasm.instructions import cnot, h, measure\n",
"\n",
"# AWS imports: Import Braket SDK modules\n",
"from braket.devices import LocalSimulator"
]
},
{
Expand Down
9 changes: 5 additions & 4 deletions examples/2_Expressing_classical_control_flow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
"source": [
"# general imports\n",
"from collections import Counter\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# AWS imports: Import Braket SDK modules\n",
"from braket.devices import LocalSimulator\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# AutoQASM imports\n",
"import autoqasm as aq\n",
"from autoqasm.instructions import measure, h, cnot"
"from autoqasm.instructions import cnot, h, measure\n",
"\n",
"# AWS imports: Import Braket SDK modules\n",
"from braket.devices import LocalSimulator"
]
},
{
Expand Down
9 changes: 5 additions & 4 deletions examples/3_1_Iterative_phase_estimation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
"# general imports\n",
"import math\n",
"from collections import Counter\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# AWS imports: Import Braket SDK modules\n",
"from braket.devices import LocalSimulator\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# AutoQASM imports\n",
"import autoqasm as aq\n",
"from autoqasm.instructions import measure, x, rz, h, cphaseshift, reset"
"from autoqasm.instructions import cphaseshift, h, measure, reset, rz, x\n",
"\n",
"# AWS imports: Import Braket SDK modules\n",
"from braket.devices import LocalSimulator"
]
},
{
Expand Down
16 changes: 8 additions & 8 deletions examples/3_2_magic_state_distillation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
"outputs": [],
"source": [
"# general imports\n",
"from collections import Counter, defaultdict\n",
"from typing import Dict, List\n",
"from collections import Counter\n",
"import numpy as np\n",
"from collections import defaultdict\n",
"\n",
"# AWS imports: Import Braket SDK modules\n",
"from braket.devices import LocalSimulator\n",
"import numpy as np\n",
"\n",
"# AutoQASM imports\n",
"import autoqasm as aq\n",
"import autoqasm.instructions as ins"
"import autoqasm.instructions as ins\n",
"\n",
"# AWS imports: Import Braket SDK modules\n",
"from braket.devices import LocalSimulator"
]
},
{
Expand Down Expand Up @@ -288,7 +288,7 @@
" ins.y(0)\n",
"\n",
" # measure ancilla\n",
" c = ins.measure([1, 2, 3, 4])"
" c = ins.measure([1, 2, 3, 4]) # noqa: F841"
]
},
{
Expand Down Expand Up @@ -409,7 +409,7 @@
"\n",
" # measuring in the basis of magic state\n",
" basis_rotation_t_type(0)\n",
" c2 = ins.measure(0)"
" c2 = ins.measure(0) # noqa: F841"
]
},
{
Expand Down
12 changes: 6 additions & 6 deletions examples/4_Native_programming.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"# general imports\n",
"import IPython\n",
"\n",
"# AWS imports: Import Braket SDK modules\n",
"from braket.devices import Devices\n",
"\n",
"# AutoQASM imports\n",
"import autoqasm as aq"
"import autoqasm as aq\n",
"\n",
"# AWS imports: Import Braket SDK modules\n",
"from braket.devices import Devices"
]
},
{
Expand Down Expand Up @@ -60,7 +60,7 @@
}
],
"source": [
"from autoqasm.instructions import h, cnot, measure\n",
"from autoqasm.instructions import cnot, h, measure\n",
"\n",
"\n",
"@aq.main\n",
Expand Down Expand Up @@ -437,7 +437,7 @@
}
],
"source": [
"from ionq_gates import h, cnot\n",
"from ionq_gates import cnot, h # noqa: F811\n",
"\n",
"\n",
"@aq.main\n",
Expand Down
10 changes: 5 additions & 5 deletions examples/5_Pulse_programming_and_dynamical_decoupling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
"# general imports\n",
"import numpy as np\n",
"\n",
"# AWS imports: Import Braket SDK modules\n",
"from braket.aws import AwsDevice\n",
"from braket.devices import Devices\n",
"\n",
"# AutoQASM imports\n",
"import autoqasm as aq\n",
"from autoqasm import pulse\n",
"from autoqasm.instructions import rx, rz"
"from autoqasm.instructions import rx, rz\n",
"\n",
"# AWS imports: Import Braket SDK modules\n",
"from braket.aws import AwsDevice\n",
"from braket.devices import Devices"
]
},
{
Expand Down
14 changes: 7 additions & 7 deletions examples/6_Customize_gate_calibrations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
"# general imports\n",
"import numpy as np\n",
"\n",
"# AWS imports: Import Braket SDK modules\n",
"from braket.aws import AwsDevice\n",
"from braket.devices import Devices\n",
"from braket.circuits import Gate, QubitSet, FreeParameter\n",
"from braket.pulse import DragGaussianWaveform\n",
"\n",
"# AutoQASM imports\n",
"import autoqasm as aq\n",
"from autoqasm import pulse\n",
"from autoqasm.instructions import rx, rz, measure"
"from autoqasm.instructions import measure, rx, rz\n",
"\n",
"# AWS imports: Import Braket SDK modules\n",
"from braket.aws import AwsDevice\n",
"from braket.circuits import FreeParameter, Gate, QubitSet\n",
"from braket.devices import Devices\n",
"from braket.pulse import DragGaussianWaveform"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions test/unit_tests/autoqasm/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import math

import pytest
from braket.devices import LocalSimulator
from braket.tasks.local_quantum_task import LocalQuantumTask

import autoqasm as aq
from autoqasm import errors
from autoqasm.instructions import cnot, h, measure, rx, x
from autoqasm.simulator import McmSimulator
from braket.devices import LocalSimulator
from braket.tasks.local_quantum_task import LocalQuantumTask


def _test_on_local_sim(program: aq.Program, inputs=None) -> None:
Expand Down
8 changes: 4 additions & 4 deletions test/unit_tests/autoqasm/test_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
from unittest.mock import Mock, patch

import pytest

import autoqasm as aq
from autoqasm import errors
from autoqasm.instructions import cnot, cphaseshift00, h, rx, x
from braket.aws import AwsDevice
from braket.device_schema import DeviceActionType
from braket.device_schema.simulators import GateModelSimulatorDeviceCapabilities
from braket.devices import Devices
from braket.parametric import FreeParameter

import autoqasm as aq
from autoqasm import errors
from autoqasm.instructions import cnot, cphaseshift00, h, rx, x

RIGETTI_REGION = "us-west-1"

MOCK_DEFAULT_S3_DESTINATION_FOLDER = (
Expand Down
4 changes: 2 additions & 2 deletions test/unit_tests/autoqasm/test_hybrid_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
from unittest.mock import MagicMock, mock_open, patch

import pytest

import autoqasm as aq
from braket.aws import AwsQuantumJob
from braket.devices import Devices
from braket.jobs.local import LocalQuantumJob

import autoqasm as aq


@pytest.fixture
def aws_session():
Expand Down
6 changes: 3 additions & 3 deletions test/unit_tests/autoqasm/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

import numpy as np
import pytest
from braket.circuits import FreeParameter
from braket.devices import LocalSimulator
from braket.tasks.local_quantum_task import LocalQuantumTask

import autoqasm as aq
from autoqasm import pulse
from autoqasm.instructions import cnot, cphaseshift, gpi, h, measure, ms, rx, rz, x
from autoqasm.simulator import McmSimulator
from braket.circuits import FreeParameter
from braket.devices import LocalSimulator
from braket.tasks.local_quantum_task import LocalQuantumTask


def _test_parametric_on_local_sim(program: aq.Program, inputs: dict[str, float]) -> np.ndarray:
Expand Down
2 changes: 1 addition & 1 deletion test/unit_tests/autoqasm/test_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

import oqpy.base
import pytest
from braket.circuits.serialization import IRType

import autoqasm as aq
from autoqasm.instructions import cnot, measure, rx
from braket.circuits.serialization import IRType


def test_program_conversion_context() -> None:
Expand Down
4 changes: 2 additions & 2 deletions test/unit_tests/autoqasm/test_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import textwrap

import pytest
from braket.parametric import FreeParameter
from braket.pulse import ArbitraryWaveform, Frame, Port

import autoqasm as aq
from autoqasm.instructions import rx
Expand All @@ -32,6 +30,8 @@
shift_frequency,
shift_phase,
)
from braket.parametric import FreeParameter
from braket.pulse import ArbitraryWaveform, Frame, Port

PORT = Port(port_id="device_port_x0", dt=1e-9, properties={})
FRAME1 = Frame(frame_id="predefined_frame_1", frequency=2e9, port=PORT, phase=0, is_predefined=True)
Expand Down
2 changes: 1 addition & 1 deletion test/unit_tests/autoqasm/test_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"""AutoQASM tests exercising the return statement for `aq.main`."""

import pytest
from braket.pulse import Frame, Port

import autoqasm as aq
from autoqasm.instructions import measure
from autoqasm.pulse import capture_v0
from braket.pulse import Frame, Port


def test_float_lit():
Expand Down
3 changes: 1 addition & 2 deletions test/unit_tests/autoqasm/test_serialization_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@

import textwrap

from braket.pulse import Frame, GaussianWaveform, Port

import autoqasm as aq
from autoqasm.program import OpenQASMSerializationProperties
from autoqasm.pulse import barrier, play
from braket.pulse import Frame, GaussianWaveform, Port

PORT = Port(port_id="device_port_x0", dt=1e-9, properties={})
FRAME = Frame(frame_id="predefined_frame_1", frequency=2e9, port=PORT, phase=0, is_predefined=True)
Expand Down
4 changes: 2 additions & 2 deletions test/unit_tests/autoqasm/test_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
# language governing permissions and limitations under the License.

import pytest
from braket.ir.openqasm import Program as OpenQASMProgram
from braket.tasks import GateModelQuantumTaskResult

from autoqasm.simulator import McmSimulator
from autoqasm.simulator.native_interpreter import NativeInterpreter
from autoqasm.simulator.program_context import McmProgramContext
from autoqasm.simulator.simulation import Simulation
from braket.ir.openqasm import Program as OpenQASMProgram
from braket.tasks import GateModelQuantumTaskResult

INPUTS_QASM = "test/resources/inputs.qasm"

Expand Down

0 comments on commit 589b392

Please sign in to comment.