Skip to content

Commit 25883cc

Browse files
authored
Merge pull request #110 from BoxiLi/qutip-qip-0.1.X
Prepare the qutip-qip-0.1.2 release
2 parents 10497b5 + bf02c91 commit 25883cc

File tree

13 files changed

+189
-63
lines changed

13 files changed

+189
-63
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.1
1+
0.1.2

doc/source/changelog.rst

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
.. _changelog:
2+
3+
**********
4+
Change Log
5+
**********
6+
7+
Version 0.1.2 (Nov 25, 2021)
8+
++++++++++++++++++++++++++++
9+
This micro release adds more thorough documentation for the project and fixes a few bugs in :obj:`.QubitCircuit` and :obj:`.Processor`.
10+
11+
PRs are collected at `https://github.com/qutip/qutip-qip/milestone/4?closed=1 <https://github.com/qutip/qutip-qip/milestone/4?closed=1>`_.
12+
13+
Improvements
14+
------------
15+
- Efficient Hadamard transform. (`#103 <https://github.com/qutip/qutip-qip/pull/103>`_)
16+
- Make circuit latex code accessible in `QubitCircuit`. (`#108 <https://github.com/qutip/qutip-qip/pull/108>`_)
17+
18+
19+
Bug Fixes
20+
----------
21+
- Fix the leaking noise objects in `Processor`. (`#89 <https://github.com/qutip/qutip-qip/pull/89>`_)
22+
- Fix a bug in time-dependent collapse operators in `Processor`. (`#107 <https://github.com/qutip/qutip-qip/pull/107>`_)
23+
24+
25+
Version 0.1.1 (July 28, 2021)
26+
+++++++++++++++++++++++++++++
27+
28+
This micro release adds more thorough documentation for the project and fixes a few bugs in :obj:`.QubitCircuit` and :obj:`.Processor`.
29+
30+
PRs are collected `here <https://github.com/qutip/qutip-qip/milestone/2?closed=1>`_.
31+
32+
Improvements
33+
------------
34+
- Improve the documentation.
35+
- Workflows for releases and automatically building the documentation, migrated from ``qutip``. (`#49 <https://github.com/qutip/qutip-qip/pull/49>`_, `#78 <https://github.com/qutip/qutip-qip/pull/78>`_)
36+
- The part of tex code taken from circuit is removed due to licence issue. Instead, the latex code now requires the user to install `qcircuit` in advance. (`#61 <https://github.com/qutip/qutip-qip/pull/61>`_)
37+
- Rename :obj:`.Noise.get_noisy_dynamics` with :obj:`.Noise.get_noisy_pulses`. The new name is more appropriate because it returns a list of :obj:`.Pulse`, not a ``QobjEvo``. The old API is deprecated. (`#76 <https://github.com/qutip/qutip-qip/pull/76>`_)
38+
- Add more thorough documentation for installing external dependencies for circuit plotting. (`#65 <https://github.com/qutip/qutip-qip/pull/65>`_)
39+
40+
Bug Fixes
41+
---------
42+
- Add the missing drift Hamiltonian to the method :obj:`.Processor.run_analytically`. It was missing because only the control part of the Hamiltonian is added. (`#74 <https://github.com/qutip/qutip-qip/pull/74>`_)
43+
- Fix a few bugs in :obj:`.QubitCircuit`: Make `QubitCircuit.propagators_no_expand` private. It will be removed and replaced by :obj:`.QubitCircuit.propagators`. The attributes :obj:`.QubitCircuit.U_list` is also removed. (`#66 <https://github.com/qutip/qutip-qip/pull/66>`_)
44+
45+
Developer Changes
46+
-----------------
47+
- Documentation is moved from ``/docs`` to ``/doc``. (`#49 <https://github.com/qutip/qutip-qip/pull/49>`_, `#78 <https://github.com/qutip/qutip-qip/pull/78>`_)
48+
49+
50+
Version 0.1.0 (May 14, 2021)
51+
++++++++++++++++++++++++++++
52+
53+
This is the first release of qutip-qip, the Quantum Information Processing package in QuTiP.
54+
55+
The qutip-qip package used to be a module ``qutip.qip`` under `QuTiP (Quantum Toolbox in Python) <http://qutip.org/index.html>`_. From QuTiP 5.0, the community has decided to decrease the size of the core QuTiP package by reducing the external dependencies, in order to simplify maintenance. Hence a few modules are separated from the core QuTiP and will become QuTiP family packages. They are still maintained by the QuTiP team but hosted under different repositories in the `QuTiP organization <https://github.com/qutip>`_.
56+
57+
The qutip-qip package, QuTiP quantum information processing, aims at providing basic tools for quantum computing simulation both for simple quantum algorithm design and for experimental realization. Compared to other libraries for quantum information processing, qutip-qip puts additional emphasis on the physics layer and the interaction with the QuTiP package. The package offers two different approaches for simulating quantum circuits, one with :obj:`.QubitCircuit` calculating unitary evolution under quantum gates by matrix product, another called :obj:`.Processor` using open system solvers in QuTiP to simulate the execution of quantum circuits on a noisy quantum device.

doc/source/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ qutip-qip: QuTiP quantum information processing
3636
contribution-code.rst
3737
contribution-docs.rst
3838

39+
.. toctree::
40+
:maxdepth: 2
41+
:caption: Changelog
42+
43+
changelog.rst
44+
3945
.. toctree::
4046
:maxdepth: 2
4147
:caption: API documentation

doc/source/qip-simulator.rst

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ method.
3939

4040
.. testcode::
4141

42-
from qutip import tensor
42+
from qutip import tensor, basis
4343
zero_state = tensor(basis(2, 0), basis(2, 0), basis(2, 0))
4444
result = qc.run(state=zero_state)
4545
wstate = result
@@ -93,42 +93,42 @@ outputs, we can use the :meth:`.QubitCircuit.run_statistics` function:
9393
.. testoutput::
9494
:options: +NORMALIZE_WHITESPACE
9595

96-
State:
97-
Quantum object: dims = [[2, 2, 2], [1, 1, 1]], shape = (8, 1), type = ket
98-
Qobj data =
99-
[[0.]
100-
[1.]
101-
[0.]
102-
[0.]
103-
[0.]
104-
[0.]
105-
[0.]
106-
[0.]]
107-
with probability 0.33333257054168813
108-
State:
109-
Quantum object: dims = [[2, 2, 2], [1, 1, 1]], shape = (8, 1), type = ket
110-
Qobj data =
111-
[[0.]
112-
[0.]
113-
[1.]
114-
[0.]
115-
[0.]
116-
[0.]
117-
[0.]
118-
[0.]]
119-
with probability 0.33333257054168813
120-
State:
121-
Quantum object: dims = [[2, 2, 2], [1, 1, 1]], shape = (8, 1), type = ket
122-
Qobj data =
123-
[[0.]
124-
[0.]
125-
[0.]
126-
[0.]
127-
[1.]
128-
[0.]
129-
[0.]
130-
[0.]]
131-
with probability 0.33333485891662384
96+
State:
97+
Quantum object: dims = [[2, 2, 2], [1, 1, 1]], shape = (8, 1), type = ket
98+
Qobj data =
99+
[[0.]
100+
[1.]
101+
[0.]
102+
[0.]
103+
[0.]
104+
[0.]
105+
[0.]
106+
[0.]]
107+
with probability 0.3333325705416881
108+
State:
109+
Quantum object: dims = [[2, 2, 2], [1, 1, 1]], shape = (8, 1), type = ket
110+
Qobj data =
111+
[[0.]
112+
[0.]
113+
[1.]
114+
[0.]
115+
[0.]
116+
[0.]
117+
[0.]
118+
[0.]]
119+
with probability 0.3333325705416881
120+
State:
121+
Quantum object: dims = [[2, 2, 2], [1, 1, 1]], shape = (8, 1), type = ket
122+
Qobj data =
123+
[[0.]
124+
[0.]
125+
[0.]
126+
[0.]
127+
[1.]
128+
[0.]
129+
[0.]
130+
[0.]]
131+
with probability 0.33333485891662384
132132

133133
The function returns a :class:`~.Result` object which contains
134134
the output states.
@@ -186,7 +186,7 @@ The :class:`.CircuitSimulator` class also enables stepping through the circuit:
186186
[0. ]
187187
[0. ]]
188188

189-
This only excutes one gate in the circuit and
189+
This only executes one gate in the circuit and
190190
allows for a better understanding of how the state evolution takes place.
191191
The method steps through both the gates and the measurements.
192192

src/qutip_qip/circuit.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ class QubitCircuit:
394394
A list of integer for the dimension of each composite system.
395395
e.g [2,2,2,2,2] for 5 qubits system. If None, qubits system
396396
will be the default option.
397+
num_cbits : int
398+
Number of classical bits in the system.
397399
398400
Examples
399401
--------
@@ -1805,7 +1807,7 @@ def latex_code(self):
18051807
code += r" & %s" % rows[m][n]
18061808
code += r" & \qw \\ " + "\n"
18071809

1808-
return code
1810+
return _latex_template % code
18091811

18101812
# This slightly convoluted dance with the conversion formats is because
18111813
# image conversion has optional dependencies. We always want the `png` and
@@ -1866,6 +1868,17 @@ def _to_qasm(self, qasm_out):
18661868
op._to_qasm(qasm_out)
18671869

18681870

1871+
_latex_template = r"""
1872+
\documentclass{standalone}
1873+
\usepackage[braket]{qcircuit}
1874+
\renewcommand{\qswap}{*=<0em>{\times}}
1875+
\begin{document}
1876+
\Qcircuit @C=1cm @R=1cm {
1877+
%s}
1878+
\end{document}
1879+
"""
1880+
1881+
18691882
class CircuitResult:
18701883

18711884
def __init__(self, final_states, probabilities, cbits=None):

src/qutip_qip/circuit_latex.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,6 @@
3939
import tempfile
4040
import warnings
4141

42-
_latex_template = r"""
43-
\documentclass{standalone}
44-
\usepackage[braket]{qcircuit}
45-
\renewcommand{\qswap}{*=<0em>{\times}}
46-
\begin{document}
47-
\Qcircuit @C=1cm @R=1cm {
48-
%s}
49-
\end{document}
50-
"""
51-
5242

5343
def _run_command(command, *args, **kwargs):
5444
"""
@@ -228,7 +218,7 @@ def image_from_latex(code, file_type="png"):
228218
try:
229219
os.chdir(temporary_dir)
230220
with open(filename + ".tex", "w") as file:
231-
file.write(_latex_template % code)
221+
file.write(code)
232222
try:
233223
_run_command((_pdflatex, '-interaction', 'batchmode',
234224
filename))
@@ -238,6 +228,11 @@ def image_from_latex(code, file_type="png"):
238228
" Perhaps you do not have it installed, or you are"
239229
" missing the LaTeX package 'qcircuit'."
240230
)
231+
message += (
232+
"The latex code is printed below. "
233+
"Please try to compile locally using pdflatex:\n"
234+
+ code
235+
)
241236
raise RuntimeError(message) from e
242237
_crop_pdf(filename + ".pdf")
243238
if file_type in _MISSING_CONVERTERS:

src/qutip_qip/device/processor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,10 +669,9 @@ def get_qobjevo(self, args=None, noisy=False):
669669
final_qu.args.update(args)
670670

671671
# bring all c_ops to the same tlist, won't need it in QuTiP 5
672-
full_tlist = self.get_full_tlist()
673672
temp = []
674673
for c_op in c_ops:
675-
temp.append(_merge_qobjevo([c_op], full_tlist))
674+
temp.append(_merge_qobjevo([c_op], final_qu.tlist))
676675
c_ops = temp
677676

678677
if noisy:

src/qutip_qip/noise.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def process_noise(pulses, noise_list, dims, t1=None, t2=None,
4444
noisy_pulses: list of :class:`.Pulse`
4545
The noisy pulses, including the system noise.
4646
"""
47+
noise_list = noise_list.copy()
4748
noisy_pulses = deepcopy(pulses)
4849
systematic_noise = Pulse(None, None, label="systematic_noise")
4950

src/qutip_qip/operations/gates.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -924,11 +924,10 @@ def hadamard_transform(N=1):
924924
Quantum object representation of the N-qubit Hadamard gate.
925925
926926
"""
927-
data = 2 ** (-N / 2) * np.array([[(-1) ** _hamming_distance(i & j)
928-
for i in range(2 ** N)]
929-
for j in range(2 ** N)])
927+
data = [[1, 1], [1, -1]]
928+
H = Qobj(data) / np.sqrt(2)
930929

931-
return Qobj(data, dims=[[2] * N, [2] * N])
930+
return tensor([H] * N)
932931

933932

934933
def _flatten(lst):

tests/test_circuit.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,10 +655,20 @@ def test_wstate(self):
655655
np.testing.assert_allclose(probs_initial, probs_final)
656656
assert sum(result_cbits[i]) == 1
657657

658+
_latex_template = r"""
659+
\documentclass{standalone}
660+
\usepackage[braket]{qcircuit}
661+
\renewcommand{\qswap}{*=<0em>{\times}}
662+
\begin{document}
663+
\Qcircuit @C=1cm @R=1cm {
664+
%s}
665+
\end{document}
666+
"""
667+
658668
def test_latex_code_teleportation_circuit(self):
659669
qc = _teleportation_circuit()
660670
latex = qc.latex_code()
661-
assert latex == "\n".join([
671+
assert latex == self._latex_template % "\n".join([
662672
r" & \lstick{c1} & \qw & \qw & \qw & \qw"
663673
r" & \qw \cwx[4] & \qw & \qw & \ctrl{2} & \qw \\ ",
664674
r" & \lstick{c0} & \qw & \qw & \qw & \qw"

0 commit comments

Comments
 (0)