Skip to content

Commit

Permalink
Feature: Code refactoring with Sourcery (#954)
Browse files Browse the repository at this point in the history
* fix: update to python 39 syntax

* fix: sourcery corrections

fix: line too long error

* fix: tests

* fix: tests

* fix: tests

* Update src/braket/circuits/circuit.py

Co-authored-by: Ashlyn Hanson <65787294+ashlhans@users.noreply.github.com>

* fix: update readme, delete .yaml

---------

Co-authored-by: Ashlyn Hanson <65787294+ashlhans@users.noreply.github.com>
  • Loading branch information
mbeach-aws and ashlhans committed Apr 17, 2024
1 parent 0cd4531 commit b492031
Show file tree
Hide file tree
Showing 102 changed files with 595 additions and 736 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ parallel = True
branch = True
source =
src
omit =
omit =
**/braket/ir/*
**/braket/device_schema/*
**/braket/schema_common/*
Expand Down
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ updates:
interval: "weekly"
commit-message:
prefix: infra

2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sphinx:
# Optionally build your docs in additional formats such as PDF
formats:
- pdf

# setting up build.os and the python version
build:
os: ubuntu-22.04
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ You can then find the generated HTML files in `build/documentation/html`.
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/amazon-braket/amazon-braket-sdk-python/labels/help%20wanted) issues is a great place to start.

## Building Integrations
The Amazon Braket SDK supports integrations with popular quantum computing frameworks such as [PennyLane](https://github.com/amazon-braket/amazon-braket-pennylane-plugin-python), [Strawberryfields](https://github.com/amazon-braket/amazon-braket-strawberryfields-plugin-python) and [DWave's Ocean library](https://github.com/amazon-braket/amazon-braket-ocean-plugin-python). These serve as a good reference for a new integration you wish to develop.
The Amazon Braket SDK supports integrations with popular quantum computing frameworks such as [PennyLane](https://github.com/amazon-braket/amazon-braket-pennylane-plugin-python), [Strawberryfields](https://github.com/amazon-braket/amazon-braket-strawberryfields-plugin-python) and [DWave's Ocean library](https://github.com/amazon-braket/amazon-braket-ocean-plugin-python). These serve as a good reference for a new integration you wish to develop.

When developing a new integration with the Amazon Braket SDK, please remember to update the [user agent header](https://datatracker.ietf.org/doc/html/rfc7231#section-5.5.3) to include version information for your integration. An example can be found [here](https://github.com/amazon-braket/amazon-braket-pennylane-plugin-python/commit/ccee35604afc2b04d83ee9103eccb2821a4256cb).
When developing a new integration with the Amazon Braket SDK, please remember to update the [user agent header](https://datatracker.ietf.org/doc/html/rfc7231#section-5.5.3) to include version information for your integration. An example can be found [here](https://github.com/amazon-braket/amazon-braket-pennylane-plugin-python/commit/ccee35604afc2b04d83ee9103eccb2821a4256cb).

## Code of Conduct

Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ Many quantum algorithms need to run multiple independent circuits, and submittin
```python
circuits = [bell for _ in range(5)]
batch = device.run_batch(circuits, shots=100)
print(batch.results()[0].measurement_counts) # The result of the first quantum task in the batch
# The result of the first quantum task in the batch
print(batch.results()[0].measurement_counts)
```

### Running a hybrid job
Expand Down Expand Up @@ -139,14 +140,14 @@ from braket.aws import AwsDevice
device = AwsDevice("arn:aws:braket:::device/qpu/rigetti/Aspen-8")

bell = Circuit().h(0).cnot(0, 1)
task = device.run(bell)
task = device.run(bell)
print(task.result().measurement_counts)
```

When you execute your task, Amazon Braket polls for a result. By default, Braket polls for 5 days; however, it is possible to change this by modifying the `poll_timeout_seconds` parameter in `AwsDevice.run`, as in the example below. Keep in mind that if your polling timeout is too short, results may not be returned within the polling time, such as when a QPU is unavailable, and a local timeout error is returned. You can always restart the polling by using `task.result()`.

```python
task = device.run(bell, poll_timeout_seconds=86400) # 1 day
task = device.run(bell, poll_timeout_seconds=86400) # 1 day
print(task.result().measurement_counts)
```

Expand Down Expand Up @@ -232,15 +233,15 @@ tox -e integ-tests -- your-arguments

### Issues and Bug Reports

If you encounter bugs or face issues while using the SDK, please let us know by posting
the issue on our [Github issue tracker](https://github.com/amazon-braket/amazon-braket-sdk-python/issues/).
If you encounter bugs or face issues while using the SDK, please let us know by posting
the issue on our [Github issue tracker](https://github.com/amazon-braket/amazon-braket-sdk-python/issues/).
For other issues or general questions, please ask on the [Quantum Computing Stack Exchange](https://quantumcomputing.stackexchange.com/questions/ask?Tags=amazon-braket).

### Feedback and Feature Requests

If you have feedback or features that you would like to see on Amazon Braket, we would love to hear from you!
[Github issues](https://github.com/amazon-braket/amazon-braket-sdk-python/issues/) is our preferred mechanism for collecting feedback and feature requests, allowing other users
to engage in the conversation, and +1 issues to help drive priority.
If you have feedback or features that you would like to see on Amazon Braket, we would love to hear from you!
[Github issues](https://github.com/amazon-braket/amazon-braket-sdk-python/issues/) is our preferred mechanism for collecting feedback and feature requests, allowing other users
to engage in the conversation, and +1 issues to help drive priority.

### Code contributors

Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
project = "amazon-braket-sdk"
version = version(project)
release = version
copyright = "{}, Amazon.com".format(datetime.datetime.now().year)
copyright = f"{datetime.datetime.now().year}, Amazon.com"

extensions = [
"sphinxcontrib.apidoc",
Expand All @@ -26,7 +26,7 @@
default_role = "py:obj"

html_theme = "sphinx_rtd_theme"
htmlhelp_basename = "{}doc".format(project)
htmlhelp_basename = f"{project}doc"

language = "en"

Expand Down
40 changes: 20 additions & 20 deletions doc/examples-adv-circuits-algorithms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,45 @@ Learn more about working with advanced circuits and algorithms.

.. toctree::
:maxdepth: 2

**********************************************************************************************************************************************************
`Grover's search algorithm <https://github.com/amazon-braket/amazon-braket-examples/blob/main/examples/advanced_circuits_algorithms/Grover/Grover.ipynb>`_
**********************************************************************************************************************************************************

This tutorial provides a step-by-step walkthrough of Grover's quantum algorithm.
You learn how to build the corresponding quantum circuit with simple modular building
blocks using the Amazon Braket SDK. You will learn how to build custom
gates that are not part of the basic gate set provided by the SDK. A custom gate can used
This tutorial provides a step-by-step walkthrough of Grover's quantum algorithm.
You learn how to build the corresponding quantum circuit with simple modular building
blocks using the Amazon Braket SDK. You will learn how to build custom
gates that are not part of the basic gate set provided by the SDK. A custom gate can used
as a core quantum gate by registering it as a subroutine.

******************************************************************************************************************************************************************************************************************
`Quantum amplitude amplification <https://github.com/amazon-braket/amazon-braket-examples/blob/main/examples/advanced_circuits_algorithms/Quantum_Amplitude_Amplification/Quantum_Amplitude_Amplification.ipynb>`_
******************************************************************************************************************************************************************************************************************

This tutorial provides a detailed discussion and implementation of the Quantum Amplitude Amplification (QAA)
algorithm using the Amazon Braket SDK. QAA is a routine in quantum computing which generalizes the idea behind
Grover's famous search algorithm, with applications across many quantum algorithms. QAA uses an iterative
approach to systematically increase the probability of finding one or multiple
target states in a given search space. In a quantum computer, QAA can be used to obtain a
This tutorial provides a detailed discussion and implementation of the Quantum Amplitude Amplification (QAA)
algorithm using the Amazon Braket SDK. QAA is a routine in quantum computing which generalizes the idea behind
Grover's famous search algorithm, with applications across many quantum algorithms. QAA uses an iterative
approach to systematically increase the probability of finding one or multiple
target states in a given search space. In a quantum computer, QAA can be used to obtain a
quadratic speedup over several classical algorithms.


************************************************************************************************************************************************************************************************
`Quantum Fourier transform <https://github.com/amazon-braket/amazon-braket-examples/blob/main/examples/advanced_circuits_algorithms/Quantum_Fourier_Transform/Quantum_Fourier_Transform.ipynb>`_
************************************************************************************************************************************************************************************************

This tutorial provides a detailed implementation of the Quantum Fourier Transform (QFT) and
its inverse using Amazon Braket's SDK. The QFT is an important subroutine to many quantum algorithms,
most famously Shor's algorithm for factoring and the quantum phase estimation (QPE) algorithm
for estimating the eigenvalues of a unitary operator.
This tutorial provides a detailed implementation of the Quantum Fourier Transform (QFT) and
its inverse using Amazon Braket's SDK. The QFT is an important subroutine to many quantum algorithms,
most famously Shor's algorithm for factoring and the quantum phase estimation (QPE) algorithm
for estimating the eigenvalues of a unitary operator.

*********************************************************************************************************************************************************************************************
`Quantum phase estimation <https://github.com/amazon-braket/amazon-braket-examples/blob/main/examples/advanced_circuits_algorithms/Quantum_Phase_Estimation/Quantum_Phase_Estimation.ipynb>`_
*********************************************************************************************************************************************************************************************

This tutorial provides a detailed implementation of the Quantum Phase Estimation (QPE)
algorithm using the Amazon Braket SDK. The QPE algorithm is designed to estimate the
eigenvalues of a unitary operator. Eigenvalue problems can be found across many
disciplines and application areas, including principal component analysis (PCA)
as used in machine learning and the solution of differential equations in mathematics, physics,
engineering and chemistry.
This tutorial provides a detailed implementation of the Quantum Phase Estimation (QPE)
algorithm using the Amazon Braket SDK. The QPE algorithm is designed to estimate the
eigenvalues of a unitary operator. Eigenvalue problems can be found across many
disciplines and application areas, including principal component analysis (PCA)
as used in machine learning and the solution of differential equations in mathematics, physics,
engineering and chemistry.
14 changes: 7 additions & 7 deletions doc/examples-braket-features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ Learn more about the indivudal features of Amazon Braket.
`Getting notifications when a quantum task completes <https://github.com/amazon-braket/amazon-braket-examples/blob/main/examples/braket_features/Getting_notifications_when_a_quantum_task_completes/Getting_notifications_when_a_quantum_task_completes.ipynb>`_
*****************************************************************************************************************************************************************************************************************************************************************

This tutorial illustrates how Amazon Braket integrates with Amazon EventBridge for
event-based processing. In the tutorial, you will learn how to configure Amazon Braket
and Amazon Eventbridge to receive text notification about quantum task completions on your phone.
This tutorial illustrates how Amazon Braket integrates with Amazon EventBridge for
event-based processing. In the tutorial, you will learn how to configure Amazon Braket
and Amazon Eventbridge to receive text notification about quantum task completions on your phone.

***********************************************************************************************************************************************************************
`Allocating Qubits on QPU Devices <https://github.com/amazon-braket/amazon-braket-examples/blob/main/examples/braket_features/Allocating_Qubits_on_QPU_Devices.ipynb>`_
***********************************************************************************************************************************************************************

This tutorial explains how you can use the Amazon Braket SDK to allocate the qubit
This tutorial explains how you can use the Amazon Braket SDK to allocate the qubit
selection for your circuits manually, when running on QPUs.

***************************************************************************************************************************************************************************************************
`Getting Devices and Checking Device Properties <https://github.com/amazon-braket/amazon-braket-examples/blob/main/examples/braket_features/Getting_Devices_and_Checking_Device_Properties.ipynb>`_
***************************************************************************************************************************************************************************************************

This example shows how to interact with the Amazon Braket GetDevice API to
retrieve Amazon Braket devices (such as simulators and QPUs) programmatically,
This example shows how to interact with the Amazon Braket GetDevice API to
retrieve Amazon Braket devices (such as simulators and QPUs) programmatically,
and how to gain access to their properties.

***********************************************************************************************************************************************************************************
`Using the tensor network simulator TN1 <https://github.com/amazon-braket/amazon-braket-examples/blob/main/examples/braket_features/Using_the_tensor_network_simulator_TN1.ipynb>`_
***********************************************************************************************************************************************************************************

This notebook introduces the Amazon Braket managed tensor network simulator, TN1.
This notebook introduces the Amazon Braket managed tensor network simulator, TN1.
You will learn about how TN1 works, how to use it, and which problems are best suited to run on TN1.


Expand Down

0 comments on commit b492031

Please sign in to comment.