Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/codecov/codecov-ac…
Browse files Browse the repository at this point in the history
…tion-4.0.1
  • Loading branch information
speller26 authored Mar 4, 2024
2 parents 43b3be8 + 4ff8f6f commit c4c012d
Show file tree
Hide file tree
Showing 122 changed files with 2,159 additions and 1,504 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/check-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ jobs:
python-version: '3.9'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -e .[test]
pip install tox
- name: Run code format checks
run: |
tox -e linters_check
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jobs:
- name: Build a binary wheel and a source tarball
run: python setup.py sdist bdist_wheel
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf # release/v1
uses: pypa/gh-action-pypi-publish@e53eb8b103ffcb59469888563dc324e3c8ba6f06 # release/v1
with:
password: ${{ secrets.pypi_token }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ __pycache__/
/build
/venv
/dist
/model.tar.gz
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# Changelog

## v1.72.2 (2024-03-04)

### Bug Fixes and Other Changes

* validate FreeParameter name

## v1.72.1 (2024-02-28)

### Bug Fixes and Other Changes

* escape slash in metrics prefix

## v1.72.0 (2024-02-27)

### Features

* FreeParameterExpression division

## v1.71.0 (2024-02-26)

### Features

* update log stream prefix for new jobs

## v1.70.3 (2024-02-21)

### Bug Fixes and Other Changes

* remove test with job creation with qpu
* use the caller's account id based on the session
* docs: add note about using env variables for endpoint

## v1.70.2 (2024-02-14)

### Bug Fixes and Other Changes
Expand Down
233 changes: 233 additions & 0 deletions pydoclint-baseline.txt

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,3 @@ exclude =
bin
build
venv
rst-roles =
# Python programming language:
py:func,py:mod,mod
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"cloudpickle==2.2.1",
"nest-asyncio",
"networkx",
"numpy",
"numpy<2",
"openpulse",
"openqasm3",
"sympy",
Expand Down
4 changes: 2 additions & 2 deletions src/braket/_sdk/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# language governing permissions and limitations under the License.

"""Version information.
Version number (major.minor.patch[-label])
Version number (major.minor.patch[-label])
"""

__version__ = "1.70.3.dev0"
__version__ = "1.72.3.dev0"
7 changes: 3 additions & 4 deletions src/braket/ahs/analog_hamiltonian_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def to_ir(self) -> ir.Program:
representation.
Returns:
Program: A representation of the circuit in the IR format.
ir.Program: A representation of the circuit in the IR format.
"""
return ir.Program(
setup=ir.Setup(ahs_register=self._register_to_ir()),
Expand All @@ -77,7 +77,7 @@ def _hamiltonian_to_ir(self) -> ir.Hamiltonian:
shiftingFields=terms[AnalogHamiltonianSimulation.SHIFTING_FIELDS_PROPERTY],
)

def discretize(self, device) -> AnalogHamiltonianSimulation: # noqa
def discretize(self, device: AwsDevice) -> AnalogHamiltonianSimulation: # noqa
"""Creates a new AnalogHamiltonianSimulation with all numerical values represented
as Decimal objects with fixed precision based on the capabilities of the device.
Expand All @@ -88,9 +88,8 @@ def discretize(self, device) -> AnalogHamiltonianSimulation: # noqa
AnalogHamiltonianSimulation: A discretized version of this program.
Raises:
DiscretizeError: If unable to discretize the program.
DiscretizationError: If unable to discretize the program.
"""

required_action_schema = DeviceActionType.AHS
if (required_action_schema not in device.properties.action) or (
device.properties.action[required_action_schema].actionType != required_action_schema
Expand Down
6 changes: 5 additions & 1 deletion src/braket/ahs/atom_arrangement.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def add(
atom (in meters). The coordinates can be a numpy array of shape (2,)
or a tuple of int, float, Decimal
site_type (SiteType): The type of site. Optional. Default is FILLED.
Returns:
AtomArrangement: returns self (to allow for chaining).
"""
Expand Down Expand Up @@ -109,6 +110,9 @@ def discretize(self, properties: DiscretizationProperties) -> AtomArrangement:
properties (DiscretizationProperties): Capabilities of a device that represent the
resolution with which the device can implement the parameters.
Raises:
DiscretizationError: If unable to discretize the program.
Returns:
AtomArrangement: A new discretized atom arrangement.
"""
Expand All @@ -117,7 +121,7 @@ def discretize(self, properties: DiscretizationProperties) -> AtomArrangement:
discretized_arrangement = AtomArrangement()
for site in self._sites:
new_coordinates = tuple(
(round(Decimal(c) / position_res) * position_res for c in site.coordinate)
round(Decimal(c) / position_res) * position_res for c in site.coordinate
)
discretized_arrangement.add(new_coordinates, site.site_type)
return discretized_arrangement
Expand Down
7 changes: 4 additions & 3 deletions src/braket/ahs/driving_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def stitch(
Returns:
DrivingField: The stitched DrivingField object.
"""

amplitude = self.amplitude.time_series.stitch(other.amplitude.time_series, boundary)
detuning = self.detuning.time_series.stitch(other.detuning.time_series, boundary)
phase = self.phase.time_series.stitch(other.phase.time_series, boundary)
Expand Down Expand Up @@ -143,8 +142,7 @@ def discretize(self, properties: DiscretizationProperties) -> DrivingField:
def from_lists(
times: list[float], amplitudes: list[float], detunings: list[float], phases: list[float]
) -> DrivingField:
"""
Builds DrivingField Hamiltonian from lists defining time evolution
"""Builds DrivingField Hamiltonian from lists defining time evolution
of Hamiltonian parameters (Rabi frequency, detuning, phase).
The values of the parameters at each time points are global for all atoms.
Expand All @@ -154,6 +152,9 @@ def from_lists(
detunings (list[float]): The values of the detuning
phases (list[float]): The values of the phase
Raises:
ValueError: If any of the input args length is different from the rest.
Returns:
DrivingField: DrivingField Hamiltonian.
"""
Expand Down
3 changes: 2 additions & 1 deletion src/braket/ahs/pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def __init__(self, series: list[Number]):
@property
def series(self) -> list[Number]:
"""list[Number]: A series of numbers representing the local
pattern of real numbers."""
pattern of real numbers.
"""
return self._series

def discretize(self, resolution: Decimal) -> Pattern:
Expand Down
9 changes: 8 additions & 1 deletion src/braket/ahs/shifting_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def terms(self) -> list[Hamiltonian]:
def magnitude(self) -> Field:
r"""Field: containing the global magnitude time series :math:`\Delta(t)`,
where time is measured in seconds (s) and values measured in rad/s)
and the local pattern :math:`h_k` of dimensionless real numbers between 0 and 1."""
and the local pattern :math:`h_k` of dimensionless real numbers between 0 and 1.
"""
return self._magnitude

@staticmethod
Expand All @@ -68,6 +69,9 @@ def from_lists(times: list[float], values: list[float], pattern: list[float]) ->
values (list[float]): The values of the shifting field
pattern (list[float]): The pattern of the shifting field
Raises:
ValueError: If the length of times and values differs.
Returns:
ShiftingField: The shifting field obtained
"""
Expand Down Expand Up @@ -99,6 +103,9 @@ def stitch(
- "left" - use the last value from the left time series as the boundary point.
- "right" - use the first value from the right time series as the boundary point.
Raises:
ValueError: The ShiftingField patterns differ.
Returns:
ShiftingField: The stitched ShiftingField object.
Expand Down
31 changes: 15 additions & 16 deletions src/braket/annealing/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from __future__ import annotations

from enum import Enum
from typing import Dict, Tuple

import braket.ir.annealing as ir

Expand All @@ -37,16 +36,16 @@ class Problem:
def __init__(
self,
problem_type: ProblemType,
linear: Dict[int, float] | None = None,
quadratic: Dict[Tuple[int, int], float] | None = None,
linear: dict[int, float] | None = None,
quadratic: dict[tuple[int, int], float] | None = None,
):
"""
"""Initialzes a `Problem`.
Args:
problem_type (ProblemType): The type of annealing problem
linear (Dict[int, float] | None): The linear terms of this problem,
linear (dict[int, float] | None): The linear terms of this problem,
as a map of variable to coefficient
quadratic (Dict[Tuple[int, int], float] | None): The quadratic terms of this problem,
quadratic (dict[tuple[int, int], float] | None): The quadratic terms of this problem,
as a map of variables to coefficient
Examples:
Expand All @@ -71,20 +70,20 @@ def problem_type(self) -> ProblemType:
return self._problem_type

@property
def linear(self) -> Dict[int, float]:
def linear(self) -> dict[int, float]:
"""The linear terms of this problem.
Returns:
Dict[int, float]: The linear terms of this problem, as a map of variable to coefficient
dict[int, float]: The linear terms of this problem, as a map of variable to coefficient
"""
return self._linear

@property
def quadratic(self) -> Dict[Tuple[int, int], float]:
def quadratic(self) -> dict[tuple[int, int], float]:
"""The quadratic terms of this problem.
Returns:
Dict[Tuple[int, int], float]: The quadratic terms of this problem,
dict[tuple[int, int], float]: The quadratic terms of this problem,
as a map of variables to coefficient
"""
return self._quadratic
Expand All @@ -102,23 +101,23 @@ def add_linear_term(self, term: int, coefficient: float) -> Problem:
self._linear[term] = coefficient
return self

def add_linear_terms(self, coefficients: Dict[int, float]) -> Problem:
def add_linear_terms(self, coefficients: dict[int, float]) -> Problem:
"""Adds linear terms to the problem.
Args:
coefficients (Dict[int, float]): A map of variable to coefficient
coefficients (dict[int, float]): A map of variable to coefficient
Returns:
Problem: This problem object
"""
self._linear.update(coefficients)
return self

def add_quadratic_term(self, term: Tuple[int, int], coefficient: float) -> Problem:
def add_quadratic_term(self, term: tuple[int, int], coefficient: float) -> Problem:
"""Adds a quadratic term to the problem.
Args:
term (Tuple[int, int]): The variables of the quadratic term
term (tuple[int, int]): The variables of the quadratic term
coefficient (float): The coefficient of the quadratic term
Returns:
Expand All @@ -127,11 +126,11 @@ def add_quadratic_term(self, term: Tuple[int, int], coefficient: float) -> Probl
self._quadratic[term] = coefficient
return self

def add_quadratic_terms(self, coefficients: Dict[Tuple[int, int], float]) -> Problem:
def add_quadratic_terms(self, coefficients: dict[tuple[int, int], float]) -> Problem:
"""Adds quadratic terms to the problem.
Args:
coefficients (Dict[Tuple[int, int], float]): A map of variables to coefficient
coefficients (dict[tuple[int, int], float]): A map of variables to coefficient
Returns:
Problem: This problem object
Expand Down
Loading

0 comments on commit c4c012d

Please sign in to comment.