Skip to content

Commit

Permalink
Merge branch 'main' into ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
AbeCoull authored Jan 30, 2024
2 parents 8eac728 + 058108c commit 1c111f9
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ jobs:
run: |
tox -e unit-tests
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
uses: codecov/codecov-action@4fe8c5f003fae66aa5ebb77cfd3e7bfbbda0b6b0 # v3.1.5
if: ${{ strategy.job-index }} == 0
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v1.68.1 (2024-01-29)

### Bug Fixes and Other Changes

* add force flag for import testing

## v1.68.0 (2024-01-25)

### Features
Expand Down
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sphinx configuration."""

import datetime

import pkg_resources
Expand Down
2 changes: 1 addition & 1 deletion src/braket/_sdk/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "1.68.1.dev0"
__version__ = "1.68.2.dev0"
6 changes: 3 additions & 3 deletions src/braket/aws/aws_quantum_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,9 @@ def _download_result(
"has_reservation_arn": self._has_reservation_arn_from_metadata(current_metadata),
}
try:
task_event[
"execution_duration"
] = self._result.additional_metadata.simulatorMetadata.executionDuration
task_event["execution_duration"] = (
self._result.additional_metadata.simulatorMetadata.executionDuration
)
except AttributeError:
pass
broadcast_event(_TaskCompletionEvent(**task_event))
Expand Down
14 changes: 11 additions & 3 deletions src/braket/aws/aws_quantum_task_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,33 @@ def _tasks_and_inputs(
]:
inputs = inputs or {}

max_inputs_tasks = 1
single_task = isinstance(
task_specifications,
(Circuit, Problem, OpenQasmProgram, BlackbirdProgram, AnalogHamiltonianSimulation),
)
single_input = isinstance(inputs, dict)

max_inputs_tasks = (
max(max_inputs_tasks, len(task_specifications)) if not single_task else max_inputs_tasks
)
max_inputs_tasks = (
max(max_inputs_tasks, len(inputs)) if not single_input else max_inputs_tasks
)

if not single_task and not single_input:
if len(task_specifications) != len(inputs):
raise ValueError("Multiple inputs and task specifications must be equal in number.")
if single_task:
task_specifications = repeat(task_specifications)
task_specifications = repeat(task_specifications, times=max_inputs_tasks)

if single_input:
inputs = repeat(inputs)
inputs = repeat(inputs, times=max_inputs_tasks)

tasks_and_inputs = zip(task_specifications, inputs)

if single_task and single_input:
tasks_and_inputs = [next(tasks_and_inputs)]
tasks_and_inputs = list(tasks_and_inputs)

tasks_and_inputs = list(tasks_and_inputs)

Expand Down
8 changes: 5 additions & 3 deletions src/braket/circuits/gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ def _to_openqasm(
for state, group in groupby(control_basis_state.as_tuple):
modifier_name = "neg" * (not state) + "ctrl"
control_modifiers += [
f"{modifier_name}"
if (num_control := len(list(group))) == 1
else f"{modifier_name}({num_control})"
(
f"{modifier_name}"
if (num_control := len(list(group))) == 1
else f"{modifier_name}({num_control})"
)
]
control_modifiers.append("")
qubits = control_qubits + target_qubits
Expand Down
8 changes: 4 additions & 4 deletions src/braket/pulse/pulse_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,10 @@ def _parse_from_calibration_schema(
argument_value.update(QubitSet(int(argument["value"])))
instr_args["qubits_or_frames"] = argument_value
elif argument["name"] in instr_args_keys:
instr_args[
argument["name"]
] = calibration_sequence._parse_arg_from_calibration_schema(
argument, waveforms, frames
instr_args[argument["name"]] = (
calibration_sequence._parse_arg_from_calibration_schema(
argument, waveforms, frames
)
)
else:
instr_args["qubits_or_frames"] = []
Expand Down
8 changes: 5 additions & 3 deletions src/braket/quantum_information/pauli_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ def weight_n_substrings(self, weight: int) -> tuple[PauliString, ...]:
substrings = []
for indices in itertools.combinations(self._nontrivial, weight):
factors = [
self._nontrivial[qubit]
if qubit in set(indices).intersection(self._nontrivial)
else "I"
(
self._nontrivial[qubit]
if qubit in set(indices).intersection(self._nontrivial)
else "I"
)
for qubit in range(self._qubit_count)
]
substrings.append(
Expand Down
14 changes: 8 additions & 6 deletions test/unit_tests/braket/aws/common_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,14 @@ def _create_task_args_and_kwargs(
create_kwargs = extra_kwargs or {}
create_kwargs.update(
{
"poll_timeout_seconds": poll_timeout_seconds
if poll_timeout_seconds is not None
else default_poll_timeout,
"poll_interval_seconds": poll_interval_seconds
if poll_interval_seconds is not None
else default_poll_interval,
"poll_timeout_seconds": (
poll_timeout_seconds if poll_timeout_seconds is not None else default_poll_timeout
),
"poll_interval_seconds": (
poll_interval_seconds
if poll_interval_seconds is not None
else default_poll_interval
),
"inputs": inputs,
"gate_definitions": gate_definitions,
"reservation_arn": reservation_arn,
Expand Down
2 changes: 1 addition & 1 deletion test/unit_tests/braket/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_for_import_cycles():
# parameterized version wasn't able to correctly detect some circular imports when running tox.
modules = get_modules_to_test()
processes = []
multiprocessing.set_start_method("spawn")
multiprocessing.set_start_method("spawn", force=True)
for module in modules:
# We create a separate process to make sure the imports do not interfere with each-other.
process = multiprocessing.Process(target=import_module, args=(module,))
Expand Down

0 comments on commit 1c111f9

Please sign in to comment.