Skip to content

Commit 1d8cc63

Browse files
authored
Merge pull request #151 from BoxiLi/qutip-qip-0.2.X
Prepare the qutip-qip-0.2.2 release
2 parents 1aaf383 + d320933 commit 1d8cc63

29 files changed

+649
-346
lines changed

.github/workflows/test.yml

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,71 @@ jobs:
1010
runs-on: ${{ matrix.os }}
1111
strategy:
1212
matrix:
13-
python-version: [3.6, 3.9]
1413
os: [ubuntu-latest, windows-latest, macOS-latest]
1514

1615
steps:
1716
- uses: actions/checkout@v2
18-
- name: Set up Python ${{ matrix.python-version }}
17+
- name: Set up Python
1918
uses: actions/setup-python@v2
2019
with:
21-
python-version: ${{ matrix.python-version }}
20+
python-version: 3.9
2221
- name: Install qutip-qip
2322
run: |
2423
python -m pip install --upgrade pip
2524
pip install -e .[tests]
26-
- name: Test with pytest
25+
- name: Test with pytest and generate coverage report
2726
run: |
28-
pytest tests --strict-config --strict-markers --verbosity=1
27+
pip install pytest-cov coveralls
28+
pytest tests --strict-markers --cov=qutip_qip --cov-report=
29+
- name: Upload to Coveralls
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.github_token }}
32+
COVERALLS_FLAG_NAME: ${{ matrix.qutip-version }}
33+
COVERALLS_PARALLEL: true
34+
run: coveralls --service=github
2935

3036
test-qutip-support:
3137
# test for qutip master branch
3238
runs-on: ubuntu-latest
39+
3340
strategy:
34-
matrix:
35-
# TODO: add dev.major and minimal supported qutip version v4.6
36-
qutip-version: ['master']
37-
41+
matrix:
42+
qutip-version: ['==4.6.*', '==4.7.*', '@dev.major']
43+
3844
steps:
3945
- uses: actions/checkout@v2
4046
- name: Set up Python
4147
uses: actions/setup-python@v2
4248
with:
43-
python-version: 3.8
49+
python-version: 3.6
4450
- name: Install dependencies
4551
run: |
4652
python -m pip install --upgrade pip
47-
python -m pip install numpy scipy cython matplotlib pytest pytest-cov coveralls
48-
- name: Install qutip
53+
python -m pip install pytest pytest-cov coveralls
54+
55+
- name: Install QuTiP from PyPI
56+
if: ${{ ! startsWith( matrix.qutip-version, '@') }}
57+
run: python -m pip install 'qutip${{ matrix.qutip-version }}'
58+
59+
- name: Install QuTiP from GitHub
60+
if: ${{ startsWith( matrix.qutip-version, '@') }}
4961
run: |
50-
pip install git+https://github.com/qutip/qutip.git
62+
python -m pip install numpy scipy cython
63+
python -m pip install 'git+https://github.com/qutip/qutip.git${{ matrix.qutip-version }}'
64+
5165
- name: Install qutip-qip
5266
# Installing in-place so that coveralls can locate the source code.
5367
run: |
54-
pip install -e .
68+
pip install -e .[full]
5569
- name: Test with pytest and generate coverage report
5670
run: |
71+
pip install pytest-cov coveralls
5772
pytest tests --strict-markers --cov=qutip_qip --cov-report=
5873
- name: Upload to Coveralls
5974
env:
6075
GITHUB_TOKEN: ${{ secrets.github_token }}
76+
COVERALLS_FLAG_NAME: ${{ matrix.qutip-version }}
77+
COVERALLS_PARALLEL: true
6178
run: coveralls --service=github
6279

6380
doctest:
@@ -83,3 +100,16 @@ jobs:
83100
python -m pip install joblib pytest pytest-custom_exit_code
84101
cd doc/pulse-paper
85102
pytest *.py --suppress-no-test-exit-code
103+
104+
finalise:
105+
name: Finalise coverage reporting
106+
needs: [test, test-qutip-support]
107+
runs-on: ubuntu-latest
108+
container: python:3-slim
109+
steps:
110+
- name: Finalise coverage reporting
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.github_token }}
113+
run: |
114+
python -m pip install coveralls
115+
coveralls --service=github --finish

.vscode/settings.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.1
1+
0.2.2

doc/pulse-paper/customize.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@
1313
plt.rcParams.update({"text.usetex": False, "font.size": 10})
1414
from joblib import Parallel, delayed # for parallel simulations
1515
import numpy as np
16-
from qutip import sigmax, sigmay, sigmaz, basis, qeye, tensor, Qobj, fock_dm
16+
from qutip import (
17+
fidelity, sigmax, sigmay, sigmaz, basis, qeye, tensor, Qobj, fock_dm)
1718
from qutip_qip.circuit import QubitCircuit, Gate
1819
from qutip_qip.device import ModelProcessor, Model
1920
from qutip_qip.compiler import GateCompiler, Instruction
20-
from qutip import Options
21+
import qutip
22+
from packaging.version import parse as parse_version
23+
if parse_version(qutip.__version__) < parse_version('5.dev'):
24+
from qutip import Options as SolverOptions
25+
else:
26+
from qutip import SolverOptions
2127
from qutip_qip.noise import Noise
2228

2329

@@ -94,6 +100,7 @@ def single_qubit_gate_compiler(self, gate, args):
94100
# gate.arg_value is the rotation angle
95101
tlist = np.abs(gate.arg_value) / self.params["pulse_amplitude"]
96102
coeff = self.params["pulse_amplitude"] * np.sign(gate.arg_value)
103+
coeff /= 2 * np.pi
97104
if gate.name == "RX":
98105
return self.generate_pulse(gate, tlist, coeff, phase=0.0)
99106
elif gate.name == "RY":
@@ -112,6 +119,7 @@ def rotation_with_phase_compiler(self, gate, args):
112119
# gate.arg_value is the pulse phase
113120
tlist = self.params["duration"]
114121
coeff = self.params["pulse_amplitude"]
122+
coeff /= 2 * np.pi
115123
return self.generate_pulse(gate, tlist, coeff, phase=gate.arg_value)
116124

117125

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

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

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

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

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

215225
# compute results of the run using a solver of choice with custom options

doc/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
numpy==1.21
2-
scipy==1.5
2+
scipy==1.7
33
qutip==4.6
44
cython==0.29
5-
sphinx==3.5
5+
sphinx==4.5
66
sphinx_rtd_theme==0.5.1
77
readthedocs-sphinx-search==0.1.0rc3
88
numpydoc==1.1

doc/source/changelog.rst

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,35 @@
22
Changelog
33
*********
44

5-
Version 0.2.1 (Feb 20, 2021)
5+
Version 0.2.2 (June 20, 2022)
6+
+++++++++++++++++++++++++++++
7+
8+
Improvements
9+
------------
10+
- Correct the spelling of Hadamard. (`#132 <https://github.com/qutip/qutip-qip/pull/132>`_)
11+
- Support the `dev.major` branch of `qutip`. (`#136 <https://github.com/qutip/qutip-qip/pull/136>`_)
12+
- Export circuit plots as png with dpi. (`#139 <https://github.com/qutip/qutip-qip/pull/139>`_)
13+
14+
Bug Fixes
15+
---------
16+
- Fix Circuit Plotting for non-reversed states. (`#137 <https://github.com/qutip/qutip-qip/pull/137>`_)
17+
- Fix add_gate behavior when supplied multiple indices. (`#142 <https://github.com/qutip/qutip-qip/pull/142>`_)
18+
- Quantum circuits inherit user gates from add_circuit. (`#144 <https://github.com/qutip/qutip-qip/pull/144>`_)
19+
20+
21+
Version 0.2.1 (Feb 20, 2022)
622
++++++++++++++++++++++++++++
723

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

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

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

1935

2036
Version 0.2.0 (Nov 26, 2021)

doc/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def qutip_qip_version():
172172
# lots of functions/classes like qutip_qip.operations. However, pay
173173
# attention that some api docs files are adjusted manually for better illustration
174174
# and should not be overwritten.
175-
# autosummary_generate = True
175+
autosummary_generate = False
176176
autosummary_imported_members = True
177177

178178
# -- Options for biblatex ---------------------------------------

doc/source/qip-basics.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Gate name Description
149149
"S" Single-qubit rotation or Z90
150150
"T" Square root of S gate
151151
"SQRTNOT" Square root of NOT gate
152-
"SNOT" Hardmard gate
152+
"SNOT" Hadamard gate
153153
"PHASEGATE" Add a phase one the state 1
154154
"CRX" Controlled rotation around x axis
155155
"CRY" Controlled rotation around y axis

setup.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ package_dir=
2828
packages = find:
2929
include_package_data = True
3030
install_requires =
31-
numpy>=1.16.6,<=1.21
31+
numpy>=1.16.6
3232
scipy>=1.0
33-
qutip>=4.6,<5
33+
qutip>=4.6
34+
packaging
3435
setup_requires =
3536
packaging
3637

src/qutip_qip/_decompose/_utility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def check_gate(gate, num_qubits):
2525
"""
2626
if not isinstance(gate, Qobj):
2727
raise TypeError("The input matrix is not a Qobj.")
28-
if not gate.check_isunitary():
28+
if not gate.isunitary:
2929
raise ValueError("Input is not unitary.")
3030
if gate.dims != [[2] * num_qubits] * 2:
3131
raise ValueError(f"Input is not a unitary on {num_qubits} qubits.")

0 commit comments

Comments
 (0)