Skip to content

Commit 172dadd

Browse files
authored
Merge pull request #274 from BoxiLi/qutip-qip-0.4.X
Prepare for qutip-qip release 0.4.1
2 parents 8a459b4 + 08db517 commit 172dadd

File tree

9 files changed

+85
-8
lines changed

9 files changed

+85
-8
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.0
1+
0.4.1

doc/source/changelog.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,25 @@ Changelog
33
*********
44

55

6-
Version 0.4.0 (Nov 23, 2024)
6+
Version 0.4.1 (April 7, 2025)
77
+++++++++++++++++++++++++++++
88

9+
This update includes improvements such as a new test for verifying that circuit files are correctly saved in PNG, TXT, and PDF formats, and the addition of a package entry point with about information. Bug fixes address a correction in the ZZ coefficients calculation in the superconducting qubits model and ensure that expand_operator outputs the expected data type.
10+
11+
Improvements
12+
------------
13+
- Add a test to verify that the Matplotlib, Text, and LaTeX renderers saves circuit files in PNG, TXT, and PDF formats. (`#260 <https://github.com/qutip/qutip-qip/pull/260>`_ by Rushiraj Gadhvi)
14+
- Add family package entry point with about information. (`#261 <https://github.com/qutip/qutip-qip/pull/261>`_ by Simon Cross)
15+
16+
Bug Fixes
17+
---------
18+
- Use ``wq`` instead of ``wr`` for ``zz_coeff`` in ``SCqubits`` modelling. (`#270 <https://github.com/qutip/qutip-qip/pull/270>`_ by Ferris Prima Nugraha)
19+
- Ensure the output of ``expand_operator`` is the expected dtype. (`#273 <https://github.com/qutip/qutip-qip/pull/273>`_ by Eric Giguère)
20+
21+
22+
Version 0.4.0 (Nov 23, 2024)
23+
++++++++++++++++++++++++++++
24+
925
This release adds two new quantum circuit renderers -- one based on matplotlib and another that renders the circuit as text -- and improves the circuit simulation speed.
1026

1127
New features

setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ setup_requires =
3838
[options.packages.find]
3939
where = src
4040

41+
[options.entry_points]
42+
qutip.family =
43+
qutip_qip = qutip_qip.family
44+
4145
[options.extras_require]
4246
graphics = matplotlib>=1.3.0
4347
control = qutip-qtrl

src/qutip_qip/device/circuitqed.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,13 @@ def _compute_params(self):
283283
if i != (num_qubits - 1):
284284
tmp += g[2 * i] ** 2 / (wq[i] - wr[i])
285285
wq_dr.append(tmp)
286-
self.params["wq_dressed"] = wq_dr
286+
self.params["wq_dressed_cavity"] = wq_dr
287287
# Dressed resonator frequency
288288
wr_dr = []
289289
for i in range(num_qubits - 1):
290290
tmp = wr[i]
291291
tmp -= g[2 * i] ** 2 / (wq[i] - wr[i] + alpha[i])
292-
tmp -= g[2 * i + 1] ** 2 / (wq[i + 1] - wr[i] + alpha[i])
292+
tmp -= g[2 * i + 1] ** 2 / (wq[i + 1] - wr[i] + alpha[i + 1])
293293
wr_dr.append(tmp)
294294
self.params["wr_dressed"] = wr_dr
295295
# Effective qubit coupling strength
@@ -305,6 +305,17 @@ def _compute_params(self):
305305
)
306306
J.append(tmp)
307307
self.params["J"] = J
308+
# Additional qubit-qubit coupling induced shift
309+
wq_dr_copy = np.copy(wq_dr) * -1
310+
for i in range(num_qubits - 1):
311+
JJ_shift = J[i] ** 2 / (wq_dr_copy[i] - wq_dr_copy[i + 1])
312+
zz_shift = -J[i] ** 2 * (
313+
1 / (wq_dr_copy[i] - wq_dr_copy[i + 1] + alpha[i])
314+
+ 1 / (-wq_dr_copy[i] + wq_dr_copy[i + 1] + alpha[i + 1])
315+
)
316+
wq_dr_copy[i] += -JJ_shift - zz_shift
317+
wq_dr_copy[i + 1] += +JJ_shift - zz_shift
318+
self.params["wq_dressed"] = wq_dr
308319
# Effective ZX strength
309320
zx_coeff = []
310321
omega_cr = self.params["omega_cr"]

src/qutip_qip/family.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""QuTiP family package entry point."""
2+
3+
from . import __version__
4+
5+
6+
def version():
7+
"""Return information to include in qutip.about()."""
8+
return "qutip-qip", __version__

src/qutip_qip/noise.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ def get_noisy_pulses(self, dims=None, pulses=None, systematic_noise=None):
563563
J = self.params["J"]
564564
wr_dr = self.params["wr_dressed"]
565565
wr = self.params["wr"]
566+
wq_dr_cav = self.params["wq_dressed_cavity"]
566567
wq_dr = self.params["wq_dressed"]
567568
wq = self.params["wq"]
568569
alpha = self.params["alpha"]
@@ -592,8 +593,8 @@ def get_noisy_pulses(self, dims=None, pulses=None, systematic_noise=None):
592593
)
593594
zz_op = tensor(z1, z2)
594595
zz_coeff = (
595-
1 / (wq[i] - wr[i] - alpha[i + 1])
596-
- 1 / (wq[i] - wr[i] + alpha[i])
596+
1 / (wq_dr_cav[i] - wq_dr_cav[i + 1] - alpha[i + 1])
597+
- 1 / (wq_dr_cav[i] - wq_dr_cav[i + 1] + alpha[i])
597598
) * J[i] ** 2
598599
systematic_noise.add_control_noise(
599600
zz_coeff * zz_op / 2,

src/qutip_qip/operations/gates.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,10 @@ def expand_operator(
13261326
for i, ind in enumerate(rest_pos):
13271327
new_order[ind] = rest_qubits[i]
13281328
id_list = [identity(dims[i]) for i in rest_pos]
1329-
return tensor([oper] + id_list).permute(new_order)
1329+
out = tensor([oper] + id_list).permute(new_order)
1330+
if parse_version(qutip.__version__) >= parse_version("5.dev"):
1331+
out = out.to(dtype)
1332+
return out
13301333

13311334

13321335
def gate_sequence_product(

tests/test_family.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
""" Tests for qutip_qip.family. """
2+
3+
import re
4+
5+
from qutip_qip import family
6+
7+
8+
class TestVersion:
9+
def test_version(self):
10+
pkg, version = family.version()
11+
assert pkg == "qutip-qip"
12+
assert re.match(r"\d+\.\d+\.\d+.*", version)

tests/test_renderer.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,27 @@ def test_matrenderer(request, qc_fixture):
170170
"""
171171
qc = request.getfixturevalue(qc_fixture)
172172

173-
with patch("matplotlib.pyplot.show"):
173+
with patch("matplotlib.pyplot.show"): # to avoid showing the plot
174174
qc.draw("matplotlib")
175+
176+
177+
@pytest.mark.parametrize("qc_fixture", ["qc1", "qc2", "qc3"])
178+
def test_circuit_saving(request, qc_fixture, tmpdir):
179+
"""
180+
Test if the different renderers can save the circuit in different formats.
181+
"""
182+
183+
qc = request.getfixturevalue(qc_fixture)
184+
185+
# test MatRenderer
186+
with patch("matplotlib.pyplot.show"): # to avoid showing the plot
187+
qc.draw("matplotlib", save=True, file_path=str(tmpdir.join("test")))
188+
assert tmpdir.join(
189+
"test.png"
190+
).check(), "MatRenderer saved PNG file not found."
191+
192+
# test TextRenderer
193+
qc.draw("text", save=True, file_path=str(tmpdir.join("test")))
194+
assert tmpdir.join(
195+
"test.txt"
196+
).check(), "TextRenderer saved TXT file not found."

0 commit comments

Comments
 (0)