Skip to content

Commit 895f5a6

Browse files
authored
Merge pull request #247 from BoxiLi/qutip-qip-0.3.X
# Version 0.3.2 Improvements ------------ - Add RZX gate to the SCQubits model. Fix bugs on the ZX strength. (#245) - Compile the documentation using qutip v5 (#246) Bug Fixes --------- - Add phi parameter to expand_operator call. (#237, issue raised by Neill Lambert) - Fix the warning on MacOS. (#240) - Fix a bug in :class:`~.QubitCircuit.add_1q_gate`. (#250, issue raised by hatlabcz Chao Zhou)
2 parents 2ff5632 + a746491 commit 895f5a6

27 files changed

+396
-267
lines changed

.github/workflows/black.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
lint:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v3
9+
- uses: actions/checkout@v4
1010
- uses: psf/black@stable
1111
with:
1212
options: "--check --diff"

.github/workflows/build.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ jobs:
4646
OVERRIDE_VERSION: ${{ github.event.inputs.override_version }}
4747

4848
steps:
49-
- uses: actions/checkout@v3
49+
- uses: actions/checkout@v4
5050

51-
- uses: actions/setup-python@v4
51+
- uses: actions/setup-python@v5
5252
name: Install Python
5353
with:
5454
# For the sdist we should be as conservative as possible with our
@@ -68,7 +68,7 @@ jobs:
6868
# dependencies are specified by our setup code.
6969
python -m build --sdist .
7070
71-
- uses: actions/upload-artifact@v3
71+
- uses: actions/upload-artifact@v4
7272
with:
7373
name: sdist
7474
path: dist/*.tar.gz
@@ -83,9 +83,9 @@ jobs:
8383
OVERRIDE_VERSION: ${{ github.event.inputs.override_version }}
8484

8585
steps:
86-
- uses: actions/checkout@v3
86+
- uses: actions/checkout@v4
8787

88-
- uses: actions/setup-python@v4
88+
- uses: actions/setup-python@v5
8989
name: Install Python
9090
with:
9191
# This is about the build environment, not the released wheel version.
@@ -105,7 +105,7 @@ jobs:
105105
# dependencies are specified by our setup code.
106106
python -m build --wheel --outdir wheelhouse .
107107
108-
- uses: actions/upload-artifact@v3
108+
- uses: actions/upload-artifact@v4
109109
with:
110110
name: wheels
111111
path: ./wheelhouse/*.whl
@@ -124,9 +124,9 @@ jobs:
124124

125125
steps:
126126
- name: Download build artifacts to local runner
127-
uses: actions/download-artifact@v3
127+
uses: actions/download-artifact@v4
128128

129-
- uses: actions/setup-python@v4
129+
- uses: actions/setup-python@v5
130130
name: Install Python
131131
with:
132132
python-version: '3.11'

.github/workflows/build_documentation.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
1313

14-
- uses: actions/setup-python@v4
14+
- uses: actions/setup-python@v5
1515
name: Install Python
1616
with:
17-
python-version: '3.9'
17+
python-version: '3.11'
1818

1919
- name: Install Pandoc
2020
run: |
@@ -27,7 +27,6 @@ jobs:
2727
2828
- name: Install qutip-qip from GitHub
2929
run: |
30-
python -mpip install qutip==4.7.3
3130
python -mpip install -e .
3231
# Install in editable mode so it doesn't matter if we import from
3332
# inside the installation directory, otherwise we can get some errors
@@ -45,7 +44,7 @@ jobs:
4544
# -T : display a full traceback if a Python exception occurs
4645
4746
- name: Upload built files
48-
uses: actions/upload-artifact@v3
47+
uses: actions/upload-artifact@v4
4948
with:
5049
name: qutip_qip_html_docs
5150
path: doc/_build/html/*

.github/workflows/test.yml

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ jobs:
1212
strategy:
1313
matrix:
1414
include:
15-
- case-name: qutip@5.0.0
15+
- case-name: qutip@5
1616
os: ubuntu-latest
17-
qutip-version: '==5.0.0'
18-
pyqir-version: ''
17+
qutip-version: '==5.*'
1918
python-version: '3.11'
2019
- case-name: [email protected]
2120
os: ubuntu-latest
@@ -39,12 +38,6 @@ jobs:
3938
qiskit-version: '==0.46.*'
4039
pyqir-version: '==0.6.2'
4140
python-version: '3.9'
42-
- case-name: qiskit+qir
43-
os: macOS-latest
44-
qutip-version: ''
45-
qiskit-version: '==0.46.*'
46-
pyqir-version: '==0.6.2'
47-
python-version: '3.9'
4841
- case-name: qiskit+qir
4942
os: ubuntu-latest
5043
qutip-version: ''
@@ -53,34 +46,40 @@ jobs:
5346
python-version: '3.9'
5447

5548
steps:
56-
- uses: actions/checkout@v3
49+
- uses: actions/checkout@v4
5750
- name: Set up Python
58-
uses: actions/setup-python@v4
51+
uses: actions/setup-python@v5
5952
with:
6053
python-version: ${{ matrix.python-version }}
6154

6255
- name: Install QuTiP from PyPI
6356
if: ${{ matrix.qutip-version != '' && ! startsWith( matrix.qutip-version, '@') }}
6457
run: python -m pip install 'qutip${{ matrix.qutip-version }}'
6558

59+
- name: Install PyQIR from PyPI
60+
if: ${{ matrix.pyqir-version != '' }}
61+
# We use each subpackage explicitly here; see https://github.com/qir-alliance/pyqir/issues/167.
62+
run: python -m pip install 'pyqir-generator${{ matrix.pyqir-version }}' 'pyqir-parser${{ matrix.pyqir-version }}'
63+
6664
- name: Install QuTiP from GitHub
6765
if: ${{ startsWith( matrix.qutip-version, '@') }}
6866
run: |
6967
python -m pip install 'git+https://github.com/qutip/qutip.git${{ matrix.qutip-version }}'
68+
69+
- name: Install qutip-qtrl from GitHub
70+
if: ${{ matrix.qutip-version == '@master' }}
71+
run: |
72+
python -m pip install 'git+https://github.com/qutip/qutip-qtrl.git${{ matrix.qutip-version }}'
7073
7174
- name: Install Qiskit from PyPI
7275
if: ${{ matrix.qiskit-version != '' }}
7376
run: python -m pip install 'qiskit${{ matrix.qiskit-version }}' 'qiskit-aer==0.14.0.1'
7477

75-
- name: Install PyQIR from PyPI
76-
if: ${{ matrix.pyqir-version != '' }}
77-
# We use each subpackage explicitly here; see https://github.com/qir-alliance/pyqir/issues/167.
78-
run: python -m pip install 'pyqir-generator${{ matrix.pyqir-version }}' 'pyqir-parser${{ matrix.pyqir-version }}'
79-
8078
- name: Install qutip-qip
8179
# Installing in-place so that coveralls can locate the source code.
8280
run: |
83-
pip install -e .[full]
81+
pip install matplotlib pytest
82+
pip install -e .
8483
- name: Test with pytest and generate coverage report
8584
run: |
8685
pip install pytest-cov coveralls
@@ -95,16 +94,15 @@ jobs:
9594
runs-on: ubuntu-latest
9695

9796
steps:
98-
- uses: actions/checkout@v3
97+
- uses: actions/checkout@v4
9998
- name: Set up Python
100-
uses: actions/setup-python@v4
99+
uses: actions/setup-python@v5
101100
with:
102-
python-version: 3.9
101+
python-version: 3.11
103102
- name: Install dependencies
104103
run: |
105104
python -m pip install --upgrade pip
106105
python -mpip install -r doc/requirements.txt
107-
pip install qutip==4.7.3
108106
pip install .
109107
- name: Test code snippets in the documentation
110108
run: |

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.1
1+
0.3.2

doc/pulse-paper/dj_algorithm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@
136136
first_two_qubits = result1.states[-1].ptrace([0,1])
137137
_, ax4 = hinton(
138138
first_two_qubits, ax=ax4,
139-
xlabels=['$|00\\rangle$', '$|01\\rangle$', '$|10\\rangle$', '$|11\\rangle$'],
140-
ylabels=['$|00\\rangle$', '$|01\\rangle$', '$|10\\rangle$', '$|11\\rangle$'])
139+
x_basis=['$|00\\rangle$', '$|01\\rangle$', '$|10\\rangle$', '$|11\\rangle$'],
140+
y_basis=['$|00\\rangle$', '$|01\\rangle$', '$|10\\rangle$', '$|11\\rangle$'])
141141
fig4.savefig("hinton.pdf")
142142
fig4.show()
143143

doc/pulse-paper/qft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# Pulse-level simulation
2424
processor = LinearSpinChain(num_qubits)
2525
processor.load_circuit(qc)
26-
options = Options(max_step=5000)
26+
options = Options(max_step=5000, rtol=1.e-8)
2727
state2 = processor.run_state(
2828
basis([2]*num_qubits, [0]*num_qubits),
2929
options=options

doc/requirements.txt

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
numpy==1.22.4
2-
scipy==1.10.0
3-
qutip==4.7.3
4-
cython==0.29.30
5-
sphinx==5.0.2
6-
sphinx_rtd_theme==1.0.0
7-
readthedocs-sphinx-search==0.1.2
8-
numpydoc==1.4.0
9-
matplotlib==3.5.2
10-
docutils==0.17.1
11-
sphinxcontrib-bibtex==2.4.2
1+
numpy==1.26.4
2+
scipy==1.13.1
3+
qutip==5.0.3.post1
4+
qutip-qtrl==0.1.3
5+
cython==3.0.11
6+
sphinx==7.4.7
7+
sphinx_rtd_theme==2.0.0
8+
readthedocs-sphinx-search==0.3.2
9+
numpydoc==1.8.0
10+
matplotlib==3.9.2
11+
docutils==0.20.1
12+
sphinxcontrib-bibtex==2.6.2
1213
pyqir-generator==0.6.2
1314
pyqir-parser==0.6.2
14-
qiskit==0.46.1
15-
qiskit-aer==0.14.0.1
15+
qiskit==0.46.2
16+
qiskit-aer==0.14.2

doc/source/changelog.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ Changelog
33
*********
44

55

6+
Version 0.3.2 (Sept 3, 2024)
7+
++++++++++++++++++++++++++++
8+
9+
Improvements
10+
------------
11+
- Add RZX gate to the SCQubits model. Fix bugs on the ZX strength. (`#245 <https://github.com/qutip/qutip-qip/pull/245>`_)
12+
- Compile the documentation using qutip v5 (`#246 <https://github.com/qutip/qutip-qip/pull/246>`_)
13+
14+
Bug Fixes
15+
---------
16+
- Add phi parameter to expand_operator call. (`#237 <https://github.com/qutip/qutip-qip/pull/237>`_ by Neill Lambert)
17+
- Fix the warning on MacOS. (`#240 <https://github.com/qutip/qutip-qip/pull/240>`_)
18+
- Fix a bug in :class:`~.QubitCircuit.add_1q_gate`. (`#250 <https://github.com/qutip/qutip-qip/pull/250>`_ issue raised by hatlabcz Chao Zhou)
19+
20+
621
Version 0.3.1 (April 21, 2024)
722
++++++++++++++++++++++++++++++
823

doc/source/qip-basics.rst

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,22 @@ full dimension of the circuit:
7575

7676
.. testoutput::
7777

78-
[Quantum object: dims = [[2, 2], [2, 2]], shape = (4, 4), type = oper, isherm = True
78+
[Quantum object: dims=[[2, 2], [2, 2]], shape=(4, 4), type='oper', dtype=CSR, isherm=True
7979
Qobj data =
8080
[[1. 0. 0. 0.]
8181
[0. 0. 1. 0.]
8282
[0. 1. 0. 0.]
83-
[0. 0. 0. 1.]], Quantum object: dims = [[2, 2], [2, 2]], shape = (4, 4), type = oper, isherm = True
83+
[0. 0. 0. 1.]], Quantum object: dims=[[2, 2], [2, 2]], shape=(4, 4), type='oper', dtype=CSR, isherm=True
8484
Qobj data =
8585
[[1. 0. 0. 0.]
8686
[0. 1. 0. 0.]
8787
[0. 0. 0. 1.]
88-
[0. 0. 1. 0.]], Quantum object: dims = [[2, 2], [2, 2]], shape = (4, 4), type = oper, isherm = True
88+
[0. 0. 1. 0.]], Quantum object: dims=[[2, 2], [2, 2]], shape=(4, 4), type='oper', dtype=CSR, isherm=True
8989
Qobj data =
9090
[[0. 0. 1. 0.]
9191
[0. 0. 0. 1.]
9292
[1. 0. 0. 0.]
93-
[0. 1. 0. 0.]], Quantum object: dims = [[2, 2], [2, 2]], shape = (4, 4), type = oper, isherm = True
93+
[0. 1. 0. 0.]], Quantum object: dims=[[2, 2], [2, 2]], shape=(4, 4), type='oper', dtype=CSR, isherm=True
9494
Qobj data =
9595
[[1. 0. 0. 0.]
9696
[0. 0. 1. 0.]
@@ -110,25 +110,25 @@ can be achieved with the argument ``expand=False`` specified to the
110110

111111
.. testoutput::
112112

113-
[Quantum object: dims = [[2, 2], [2, 2]], shape = (4, 4), type = oper, isherm = True
114-
Qobj data =
115-
[[1. 0. 0. 0.]
116-
[0. 0. 1. 0.]
117-
[0. 1. 0. 0.]
118-
[0. 0. 0. 1.]], Quantum object: dims = [[2, 2], [2, 2]], shape = (4, 4), type = oper, isherm = True
119-
Qobj data =
120-
[[1. 0. 0. 0.]
121-
[0. 1. 0. 0.]
122-
[0. 0. 0. 1.]
123-
[0. 0. 1. 0.]], Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True
124-
Qobj data =
125-
[[0. 1.]
126-
[1. 0.]], Quantum object: dims = [[2, 2], [2, 2]], shape = (4, 4), type = oper, isherm = True
127-
Qobj data =
128-
[[1. 0. 0. 0.]
129-
[0. 0. 1. 0.]
130-
[0. 1. 0. 0.]
131-
[0. 0. 0. 1.]]]
113+
[Quantum object: dims=[[2, 2], [2, 2]], shape=(4, 4), type='oper', dtype=Dense, isherm=True
114+
Qobj data =
115+
[[1. 0. 0. 0.]
116+
[0. 0. 1. 0.]
117+
[0. 1. 0. 0.]
118+
[0. 0. 0. 1.]], Quantum object: dims=[[2, 2], [2, 2]], shape=(4, 4), type='oper', dtype=Dense, isherm=True
119+
Qobj data =
120+
[[1. 0. 0. 0.]
121+
[0. 1. 0. 0.]
122+
[0. 0. 0. 1.]
123+
[0. 0. 1. 0.]], Quantum object: dims=[[2], [2]], shape=(2, 2), type='oper', dtype=Dense, isherm=True
124+
Qobj data =
125+
[[0. 1.]
126+
[1. 0.]], Quantum object: dims=[[2, 2], [2, 2]], shape=(4, 4), type='oper', dtype=Dense, isherm=True
127+
Qobj data =
128+
[[1. 0. 0. 0.]
129+
[0. 0. 1. 0.]
130+
[0. 1. 0. 0.]
131+
[0. 0. 0. 1.]]]
132132

133133
.. _quantum_gates:
134134

@@ -195,7 +195,7 @@ gate function returning a :class:`qutip.Qobj` and save it in the attribute ``use
195195

196196
def user_gate1(arg_value):
197197
# controlled rotation X
198-
mat = np.zeros((4, 4), dtype=np.complex)
198+
mat = np.zeros((4, 4), dtype=np.complex128)
199199
mat[0, 0] = mat[1, 1] = 1.
200200
mat[2:4, 2:4] = rx(arg_value).full()
201201
return Qobj(mat, dims=[[2, 2], [2, 2]])
@@ -229,7 +229,7 @@ gate function returning a :class:`qutip.Qobj` and save it in the attribute ``use
229229
.. testoutput::
230230
:options: +NORMALIZE_WHITESPACE
231231

232-
Quantum object: dims = [[2, 2], [2, 2]], shape = (4, 4), type = oper, isherm = False
232+
Quantum object: dims=[[2, 2], [2, 2]], shape=(4, 4), type='oper', dtype=CSR, isherm=False
233233
Qobj data =
234234
[[1. +0.j 0. +0.j 0. +0.j 0. +0.j ]
235235
[0. +0.j 1. +0.j 0. +0.j 0. +0.j ]
@@ -246,7 +246,7 @@ gate function returning a :class:`qutip.Qobj` and save it in the attribute ``use
246246
:options: +NORMALIZE_WHITESPACE
247247

248248

249-
Quantum object: dims = [[2, 2], [2, 2]], shape = (4, 4), type = oper, isherm = False
249+
Quantum object: dims=[[2, 2], [2, 2]], shape=(4, 4), type='oper', dtype=CSR, isherm=False
250250
Qobj data =
251251
[[1. +0.j 0. +0.j 0. +0.j 0. +0.j ]
252252
[0. +0.j 0.70711+0.j 0. +0.j 0. -0.70711j]
@@ -263,12 +263,12 @@ gate function returning a :class:`qutip.Qobj` and save it in the attribute ``use
263263
.. testoutput::
264264
:options: +NORMALIZE_WHITESPACE
265265

266-
Quantum object: dims = [[2, 2], [2, 2]], shape = (4, 4), type = oper, isherm = False
267-
Qobj data =
268-
[[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
269-
[0.+0.j 0.+1.j 0.+0.j 0.+0.j]
270-
[0.+0.j 0.+0.j 1.+0.j 0.+0.j]
271-
[0.+0.j 0.+0.j 0.+0.j 0.+1.j]]
266+
Quantum object: dims=[[2, 2], [2, 2]], shape=(4, 4), type='oper', dtype=CSR, isherm=False
267+
Qobj data =
268+
[[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
269+
[0.+0.j 0.+1.j 0.+0.j 0.+0.j]
270+
[0.+0.j 0.+0.j 1.+0.j 0.+0.j]
271+
[0.+0.j 0.+0.j 0.+0.j 0.+1.j]]
272272

273273
.. _quantum_circuit_plots:
274274

0 commit comments

Comments
 (0)