Skip to content

Commit

Permalink
run pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick committed Feb 3, 2024
1 parent 53a1b17 commit d2e17be
Show file tree
Hide file tree
Showing 40 changed files with 3,562 additions and 4,397 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
- uses: psf/black@stable
with:
options: "--check --diff"
src: "./src"
src: "./src"
10 changes: 3 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:
description: "Override version number (optional):"
default: ""


jobs:
# The deploy_test job is part of the test of whether we should deploy to PyPI.
# The job will succeed if either the confirmation reference is empty or if the
Expand All @@ -37,7 +36,6 @@ jobs:
echo "Full build and deploy. Wheels and source will be uploaded to PyPI."
fi
build_sdist:
name: Build sdist on Ubuntu
needs: deploy_test
Expand All @@ -54,7 +52,7 @@ jobs:
# For the sdist we should be as conservative as possible with our
# Python version. This should be the lowest supported version. This
# means that no unsupported syntax can sneak through.
python-version: '3.10'
python-version: "3.10"

- name: Install pip build
run: |
Expand All @@ -74,7 +72,6 @@ jobs:
path: dist/*.tar.gz
if-no-files-found: error


build_wheels:
name: Build wheels
needs: deploy_test
Expand All @@ -89,7 +86,7 @@ jobs:
name: Install Python
with:
# This is about the build environment, not the released wheel version.
python-version: '3.10'
python-version: "3.10"

- name: Install pip build
run: |
Expand All @@ -111,7 +108,6 @@ jobs:
path: ./wheelhouse/*.whl
if-no-files-found: error


deploy:
name: "Deploy to PyPI if desired"
# The confirmation is tested explicitly in `deploy_test`, so we know it is
Expand All @@ -129,7 +125,7 @@ jobs:
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.10'
python-version: "3.10"

- name: Verify this is not a dev version
shell: bash
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/build_documentation.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Build HTML documentation

on:
[push, pull_request]
on: [push, pull_request]

jobs:
build:
Expand All @@ -14,8 +13,8 @@ jobs:
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.8'
python-version: "3.8"

- name: Install Pandoc
run: |
sudo apt update
Expand Down
113 changes: 56 additions & 57 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Tests

on:
push:
branches: [ master ]
branches: [master]
pull_request:

jobs:
Expand All @@ -14,77 +14,76 @@ jobs:
include:
- case-name: ubuntu-python3.10
os: ubuntu-latest
qutip-version: '@master'
python-version: '3.10'
qutip-version: "@master"
python-version: "3.10"
- case-name: macOs-python3.10
os: macOS-latest
qutip-version: '@master'
python-version: '3.10'
qutip-version: "@master"
python-version: "3.10"
- case-name: windows-python3.10
os: windows-latest
qutip-version: '@master'
python-version: '3.10'
qutip-version: "@master"
python-version: "3.10"

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install QuTiP from GitHub
if: ${{ matrix.qutip-version == '@master'}}
run: |
python -m pip install 'git+https://github.com/qutip/qutip.git${{ matrix.qutip-version }}'
- name: Install qutip-qtrl from GitHub
if: ${{ matrix.qutip-version == '@master'}}
run: |
python -m pip install 'git+https://github.com/qutip/qutip-qtrl.git'
- name: Install QuTiP from GitHub
if: ${{ matrix.qutip-version == '@master'}}
run: |
python -m pip install 'git+https://github.com/qutip/qutip.git${{ matrix.qutip-version }}'
- name: Install qutip-jax from GitHub
if: ${{ matrix.qutip-version == '@master'}}
run: |
python -m pip install 'git+https://github.com/qutip/qutip-jax.git'
- name: Install qutip-qtrl from GitHub
if: ${{ matrix.qutip-version == '@master'}}
run: |
python -m pip install 'git+https://github.com/qutip/qutip-qtrl.git'
- name: Install qutip-jax from GitHub
if: ${{ matrix.qutip-version == '@master'}}
run: |
python -m pip install 'git+https://github.com/qutip/qutip-jax.git'
- name: Install qutip-qoc
# Installing in-place so that coveralls can locate the source code.
run: |
pip install -e .[full]
- name: Test with pytest and generate coverage report
run: |
pip install pytest-cov coveralls
pytest tests --strict-markers --cov=qutip_qoc --cov-report= --color=yes
- name: Upload to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
COVERALLS_PARALLEL: true
run: coveralls --service=github
- name: Install qutip-qoc
# Installing in-place so that coveralls can locate the source code.
run: |
pip install -e .[full]
- name: Test with pytest and generate coverage report
run: |
pip install pytest-cov coveralls
pytest tests --strict-markers --cov=qutip_qoc --cov-report= --color=yes
- name: Upload to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
COVERALLS_PARALLEL: true
run: coveralls --service=github

doctest:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.10
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -mpip install -r doc/requirements.txt
pip install .
- name: Test code snippets in the documentation
run: |
cd doc
make doctest
- name: Test code examples for the pulse paper
run: |
python -m pip install joblib pytest pytest-custom_exit_code
cd doc/pulse-paper
pytest *.py --suppress-no-test-exit-code
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.10
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -mpip install -r doc/requirements.txt
pip install .
- name: Test code snippets in the documentation
run: |
cd doc
make doctest
- name: Test code examples for the pulse paper
run: |
python -m pip install joblib pytest pytest-custom_exit_code
cd doc/pulse-paper
pytest *.py --suppress-no-test-exit-code
finalise:
name: Finalise coverage reporting
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ dmypy.json
.pyre/

# Visual Studio Code
.vscode/
.vscode/
12 changes: 6 additions & 6 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ We are committed to making participation in this project a harassment-free exper

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
* Other unethical or unprofessional conduct
- The use of sexualized language or imagery
- Personal attacks
- Trolling or insulting/derogatory comments
- Public or private harassment
- Publishing other's private information, such as physical or electronic addresses, without explicit permission
- Other unethical or unprofessional conduct

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.

Expand Down
50 changes: 29 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
# QuTiP - Quantum Optimal Control

The qutip-qoc package builds up on the ``qutip-qtrl`` [package](https://github.com/qutip/qutip-qtrl).
The qutip-qoc package builds up on the `qutip-qtrl` [package](https://github.com/qutip/qutip-qtrl).

It enhances it by providing two additional algorithms to optimize analytically defined control functions.
The first one is an extension of Gradient Optimization of Analytic conTrols [(GOAT)](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.120.150401).
The second leverages QuTiPs version 5 new diffrax abilities to directly calculate gradients of JAX defined contol functinos using automatic differentiation.
The second leverages QuTiPs version 5 new diffrax abilities to directly calculate gradients of JAX defined contol functinos using automatic differentiation.

The procedure consists of a two-layer approach to find global optimal values for parameterized analytical control functions.
The global optimization layer provides ``scipy.optimize.dual_annealing`` and ``scipy.optimize.basinhopping``, while the local minimization layer supports all
gradient driven ``scipy.optimize.minimize`` methods.
The global optimization layer provides `scipy.optimize.dual_annealing` and `scipy.optimize.basinhopping`, while the local minimization layer supports all
gradient driven `scipy.optimize.minimize` methods.

The package also aims for a more general way of defining control problems with QuTiP and makes switching between the four control algorithms very easy.

As with qutip-qtrl, the qutip-qoc package aims at providing advanced tools for the optimal control of quantum devices.
Compared to other libraries for quantum optimal control, qutip-qoc puts additional emphasis on the physics layer and the interaction with the QuTiP package.
Along with the extended GOAT and JOAT algorithms the package offers support for both the CRAB and GRAPE methods defined in ``qutip-qtrl``.
Along with the extended GOAT and JOAT algorithms the package offers support for both the CRAB and GRAPE methods defined in `qutip-qtrl`.

If you would like to know the future development plan and ideas, have a look at the [qutip documentation for ideas](https://qutip.org/docs/latest/development/ideas.html).

Quick start
-----------
## Quick start

To install the package, use

```
pip install qutip-qoc
```

Documentation and tutorials
---------------------------
## Documentation and tutorials

The documentation of `qutip-qoc` updated to the latest development version is hosted at [qutip-qoc.readthedocs.io/](https://qutip-qoc.readthedocs.io/en/stable/).
Tutorials related to using quantum optimal control in `qutip-qoc` can be found [*here*](https://qutip.org/qutip-tutorials/#optimal-control).
Tutorials related to using quantum optimal control in `qutip-qoc` can be found [_here_](https://qutip.org/qutip-tutorials/#optimal-control).

## Installation from source

Installation from source
------------------------
If you want to edit the source code, please download the source code and run the following command under the root `qutip-qoc` folder,

```
pip install --upgrade pip
pip install -e .
```
which makes sure that you are up to date with the latest `pip` version. Contribution guidelines are available [*here*](https://qutip-qoc.readthedocs.io/en/latest/contribution-code.html).

which makes sure that you are up to date with the latest `pip` version. Contribution guidelines are available [_here_](https://qutip-qoc.readthedocs.io/en/latest/contribution-code.html).

To build and test the documentation, additional packages need to be installed:

Expand All @@ -46,28 +49,33 @@ pip install pytest matplotlib sphinx sphinxcontrib-bibtex numpydoc sphinx_rtd_th
```

Under the `doc` directory, use

```
make html
```

to build the documentation, or

```
make doctest
```

to test the code in the documentation.

Testing
-------
## Testing

To test the installation, choose the correct branch that matches with the version, e.g., `qutip-qoc-0.2.X` for version 0.2. Then download the source code and run from the `qutip-qoc` directory.

```
pytest tests
```

Citing `qutip-qoc`
-------------------
## Citing `qutip-qoc`

If you use `qutip-qoc` in your research, please cite the original QuTiP papers that are available [here](https://dml.riken.jp/?s=QuTiP).

Support
-------
## Support

This package is supported and maintained by the same developers group as QuTiP.

[![Powered by NumFOCUS](https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A)](https://numfocus.org)
Expand All @@ -77,8 +85,8 @@ QuTiP development is supported by [Nori's lab](http://dml.riken.jp/)
at RIKEN, by the University of Sherbrooke, by Chalmers University of Technology, by Macquarie University and by Aberystwyth University,
[among other supporting organizations](http://qutip.org/#supporting-organizations).

License
-------
## License

[![license](https://img.shields.io/badge/license-New%20BSD-blue.svg)](http://en.wikipedia.org/wiki/BSD_licenses#3-clause_license_.28.22Revised_BSD_License.22.2C_.22New_BSD_License.22.2C_or_.22Modified_BSD_License.22.29)

You are free to use this software, with or without modification, provided that the conditions listed in the LICENSE.txt file are satisfied.
2 changes: 1 addition & 1 deletion doc/apidoc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ Internal interfaces to the optimal control features.

qutip_qoc.analytical_control
qutip_qoc.goat
qutip_qoc.joat
qutip_qoc.joat
Loading

0 comments on commit d2e17be

Please sign in to comment.