Skip to content

Commit

Permalink
Merge pull request #151 from BoxiLi/qutip-qip-0.2.X
Browse files Browse the repository at this point in the history
Prepare the qutip-qip-0.2.2 release
  • Loading branch information
BoxiLi committed Jun 19, 2022
2 parents 1aaf383 + d320933 commit 1d8cc63
Show file tree
Hide file tree
Showing 29 changed files with 649 additions and 346 deletions.
58 changes: 44 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,71 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.6, 3.9]
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
python-version: 3.9
- name: Install qutip-qip
run: |
python -m pip install --upgrade pip
pip install -e .[tests]
- name: Test with pytest
- name: Test with pytest and generate coverage report
run: |
pytest tests --strict-config --strict-markers --verbosity=1
pip install pytest-cov coveralls
pytest tests --strict-markers --cov=qutip_qip --cov-report=
- name: Upload to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
COVERALLS_FLAG_NAME: ${{ matrix.qutip-version }}
COVERALLS_PARALLEL: true
run: coveralls --service=github

test-qutip-support:
# test for qutip master branch
runs-on: ubuntu-latest

strategy:
matrix:
# TODO: add dev.major and minimal supported qutip version v4.6
qutip-version: ['master']

matrix:
qutip-version: ['==4.6.*', '==4.7.*', '@dev.major']

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install numpy scipy cython matplotlib pytest pytest-cov coveralls
- name: Install qutip
python -m pip install pytest pytest-cov coveralls
- name: Install QuTiP from PyPI
if: ${{ ! startsWith( matrix.qutip-version, '@') }}
run: python -m pip install 'qutip${{ matrix.qutip-version }}'

- name: Install QuTiP from GitHub
if: ${{ startsWith( matrix.qutip-version, '@') }}
run: |
pip install git+https://github.com/qutip/qutip.git
python -m pip install numpy scipy cython
python -m pip install 'git+https://github.com/qutip/qutip.git${{ matrix.qutip-version }}'
- name: Install qutip-qip
# Installing in-place so that coveralls can locate the source code.
run: |
pip install -e .
pip install -e .[full]
- name: Test with pytest and generate coverage report
run: |
pip install pytest-cov coveralls
pytest tests --strict-markers --cov=qutip_qip --cov-report=
- name: Upload to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
COVERALLS_FLAG_NAME: ${{ matrix.qutip-version }}
COVERALLS_PARALLEL: true
run: coveralls --service=github

doctest:
Expand All @@ -83,3 +100,16 @@ jobs:
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
needs: [test, test-qutip-support]
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Finalise coverage reporting
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
run: |
python -m pip install coveralls
coveralls --service=github --finish
7 changes: 0 additions & 7 deletions .vscode/settings.json

This file was deleted.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.1
0.2.2
18 changes: 14 additions & 4 deletions doc/pulse-paper/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@
plt.rcParams.update({"text.usetex": False, "font.size": 10})
from joblib import Parallel, delayed # for parallel simulations
import numpy as np
from qutip import sigmax, sigmay, sigmaz, basis, qeye, tensor, Qobj, fock_dm
from qutip import (
fidelity, sigmax, sigmay, sigmaz, basis, qeye, tensor, Qobj, fock_dm)
from qutip_qip.circuit import QubitCircuit, Gate
from qutip_qip.device import ModelProcessor, Model
from qutip_qip.compiler import GateCompiler, Instruction
from qutip import Options
import qutip
from packaging.version import parse as parse_version
if parse_version(qutip.__version__) < parse_version('5.dev'):
from qutip import Options as SolverOptions
else:
from qutip import SolverOptions
from qutip_qip.noise import Noise


Expand Down Expand Up @@ -94,6 +100,7 @@ def single_qubit_gate_compiler(self, gate, args):
# gate.arg_value is the rotation angle
tlist = np.abs(gate.arg_value) / self.params["pulse_amplitude"]
coeff = self.params["pulse_amplitude"] * np.sign(gate.arg_value)
coeff /= 2 * np.pi
if gate.name == "RX":
return self.generate_pulse(gate, tlist, coeff, phase=0.0)
elif gate.name == "RY":
Expand All @@ -112,6 +119,7 @@ def rotation_with_phase_compiler(self, gate, args):
# gate.arg_value is the pulse phase
tlist = self.params["duration"]
coeff = self.params["pulse_amplitude"]
coeff /= 2 * np.pi
return self.generate_pulse(gate, tlist, coeff, phase=gate.arg_value)


Expand All @@ -121,14 +129,16 @@ def rotation_with_phase_compiler(self, gate, args):
circuit = QubitCircuit(1)
circuit.add_gate("RX", targets=0, arg_value=np.pi / 2)
circuit.add_gate("Z", targets=0)
result1 = circuit.run(basis(2, 0))

myprocessor = ModelProcessor(model=MyModel(num_qubits))
myprocessor.native_gates = ["RX", "RY"]

mycompiler = MyCompiler(num_qubits, {"pulse_amplitude": 0.02})

myprocessor.load_circuit(circuit, compiler=mycompiler)
result = myprocessor.run_state(basis(2, 0))
result2 = myprocessor.run_state(basis(2, 0)).states[-1]
assert(abs(fidelity(result1, result2) - 1) < 1.e-5)

fig, ax = myprocessor.plot_pulses(
figsize=(LINEWIDTH * 0.7, LINEWIDTH / 2 * 0.7), dpi=200,
Expand Down Expand Up @@ -209,7 +219,7 @@ def single_crosstalk_simulation(num_gates):
init_state = tensor(
[Qobj([[init_fid, 0], [0, 0.025]]), Qobj([[init_fid, 0], [0, 0.025]])]
)
options = Options(nsteps=10000) # increase the maximal allowed steps
options = SolverOptions(nsteps=10000) # increase the maximal allowed steps
e_ops = [tensor([qeye(2), fock_dm(2)])] # observable

# compute results of the run using a solver of choice with custom options
Expand Down
4 changes: 2 additions & 2 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
numpy==1.21
scipy==1.5
scipy==1.7
qutip==4.6
cython==0.29
sphinx==3.5
sphinx==4.5
sphinx_rtd_theme==0.5.1
readthedocs-sphinx-search==0.1.0rc3
numpydoc==1.1
Expand Down
24 changes: 20 additions & 4 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,35 @@
Changelog
*********

Version 0.2.1 (Feb 20, 2021)
Version 0.2.2 (June 20, 2022)
+++++++++++++++++++++++++++++

Improvements
------------
- Correct the spelling of Hadamard. (`#132 <https://github.com/qutip/qutip-qip/pull/132>`_)
- Support the `dev.major` branch of `qutip`. (`#136 <https://github.com/qutip/qutip-qip/pull/136>`_)
- Export circuit plots as png with dpi. (`#139 <https://github.com/qutip/qutip-qip/pull/139>`_)

Bug Fixes
---------
- Fix Circuit Plotting for non-reversed states. (`#137 <https://github.com/qutip/qutip-qip/pull/137>`_)
- Fix add_gate behavior when supplied multiple indices. (`#142 <https://github.com/qutip/qutip-qip/pull/142>`_)
- Quantum circuits inherit user gates from add_circuit. (`#144 <https://github.com/qutip/qutip-qip/pull/144>`_)


Version 0.2.1 (Feb 20, 2022)
++++++++++++++++++++++++++++

This release includes a revision of the documentation and adds more code examples in the API doc strings.

Bug Fixes
---------
- Remove the check on the initial state dimension in ``QubitCircuit.run()`` (#127 <https://github.com/qutip/qutip-qip/pull/127>`_)
- Remove the check on the initial state dimension in ``QubitCircuit.run()`` (`#127 <https://github.com/qutip/qutip-qip/pull/127>`_)

Improvements
------------
- Rewrite the documentation for the pulse-level simulation. (#121 <https://github.com/qutip/qutip-qip/pull/121>`_)
- Add more code examples in the doc strings. (#126 <https://github.com/qutip/qutip-qip/pull/126>`_)
- Rewrite the documentation for the pulse-level simulation. (`#121 <https://github.com/qutip/qutip-qip/pull/121>`_)
- Add more code examples in the doc strings. (`#126 <https://github.com/qutip/qutip-qip/pull/126>`_)


Version 0.2.0 (Nov 26, 2021)
Expand Down
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def qutip_qip_version():
# lots of functions/classes like qutip_qip.operations. However, pay
# attention that some api docs files are adjusted manually for better illustration
# and should not be overwritten.
# autosummary_generate = True
autosummary_generate = False
autosummary_imported_members = True

# -- Options for biblatex ---------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion doc/source/qip-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ Gate name Description
"S" Single-qubit rotation or Z90
"T" Square root of S gate
"SQRTNOT" Square root of NOT gate
"SNOT" Hardmard gate
"SNOT" Hadamard gate
"PHASEGATE" Add a phase one the state 1
"CRX" Controlled rotation around x axis
"CRY" Controlled rotation around y axis
Expand Down
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ package_dir=
packages = find:
include_package_data = True
install_requires =
numpy>=1.16.6,<=1.21
numpy>=1.16.6
scipy>=1.0
qutip>=4.6,<5
qutip>=4.6
packaging
setup_requires =
packaging

Expand Down
2 changes: 1 addition & 1 deletion src/qutip_qip/_decompose/_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def check_gate(gate, num_qubits):
"""
if not isinstance(gate, Qobj):
raise TypeError("The input matrix is not a Qobj.")
if not gate.check_isunitary():
if not gate.isunitary:
raise ValueError("Input is not unitary.")
if gate.dims != [[2] * num_qubits] * 2:
raise ValueError(f"Input is not a unitary on {num_qubits} qubits.")

0 comments on commit 1d8cc63

Please sign in to comment.