Skip to content

Commit 7165f80

Browse files
committed
fix: remove jupyter-execute blocks
The Jupyter Sphinx integration is currently unable to properly suppress warnings resulting in prints to stderr [1]. This causes the docs to fail building properly. Qiskit Terra already removed the usage of `jupyter-execute` statements a while ago [2], so we are following suit in this regard, too. [1]: jupyter/jupyter-sphinx#178 [2]: Qiskit/qiskit#9346
1 parent 39479db commit 7165f80

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

qiskit_nature/second_q/hamiltonians/lattices/hyper_cubic_lattice.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of Qiskit.
22
#
3-
# (C) Copyright IBM 2021, 2022.
3+
# (C) Copyright IBM 2021, 2023.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -30,7 +30,7 @@ class HyperCubicLattice(Lattice):
3030
tuples of `size`, `edge_parameters`, and `boundary_conditions`.
3131
For example,
3232
33-
.. jupyter-execute::
33+
.. code-block:: python
3434
3535
from qiskit_nature.second_q.hamiltonians.lattices import (
3636
BoundaryCondition,

qiskit_nature/second_q/operators/fermionic_op.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class FermionicOp(SparseLabelOp):
4646
A ``FermionicOp`` is initialized with a dictionary, mapping terms to their respective
4747
coefficients:
4848
49-
.. jupyter-execute::
49+
.. code-block:: python
5050
5151
from qiskit_nature.second_q.operators import FermionicOp
5252
@@ -62,7 +62,7 @@ class FermionicOp(SparseLabelOp):
6262
If you have very restricted memory resources available, or would like to avoid the additional
6363
copy, the dictionary will be stored by reference if you disable ``copy`` like so:
6464
65-
.. jupyter-execute::
65+
.. code-block:: python
6666
6767
some_big_data = {
6868
"+_0 -_0": 1.0,
@@ -91,40 +91,40 @@ class FermionicOp(SparseLabelOp):
9191
9292
Addition
9393
94-
.. jupyter-execute::
94+
.. code-block:: python
9595
9696
FermionicOp({"+_1": 1}, num_spin_orbitals=2) + FermionicOp({"+_0": 1}, num_spin_orbitals=2)
9797
9898
Sum
9999
100-
.. jupyter-execute::
100+
.. code-block:: python
101101
102102
sum(FermionicOp({label: 1}, num_spin_orbitals=3) for label in ["+_0", "-_1", "+_2 -_2"])
103103
104104
Scalar multiplication
105105
106-
.. jupyter-execute::
106+
.. code-block:: python
107107
108108
0.5 * FermionicOp({"+_1": 1}, num_spin_orbitals=2)
109109
110110
Operator multiplication
111111
112-
.. jupyter-execute::
112+
.. code-block:: python
113113
114114
op1 = FermionicOp({"+_0 -_1": 1}, num_spin_orbitals=2)
115115
op2 = FermionicOp({"-_0 +_0 +_1": 1}, num_spin_orbitals=2)
116116
print(op1 @ op2)
117117
118118
Tensor multiplication
119119
120-
.. jupyter-execute::
120+
.. code-block:: python
121121
122122
op = FermionicOp({"+_0 -_1": 1}, num_spin_orbitals=2)
123123
print(op ^ op)
124124
125125
Adjoint
126126
127-
.. jupyter-execute::
127+
.. code-block:: python
128128
129129
FermionicOp({"+_0 -_1": 1j}, num_spin_orbitals=2).adjoint()
130130

qiskit_nature/second_q/operators/polynomial_tensor.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class PolynomialTensor(LinearMixin, GroupMixin, TolerancesMixin, Mapping):
7979
made about the *contents* of the keys. However, the length of each key determines the dimension
8080
of the matrix which it maps, too. For example:
8181
82-
.. jupyter-execute::
82+
.. code-block:: python
8383
8484
import numpy as np
8585
@@ -96,7 +96,7 @@ class PolynomialTensor(LinearMixin, GroupMixin, TolerancesMixin, Mapping):
9696
axis of the matrix, when an operator gets built from the tensor. This means, that the previous
9797
example would expand for example like so:
9898
99-
.. jupyter-execute::
99+
.. code-block:: python
100100
101101
from qiskit_nature.second_q.operators import FermionicOp, PolynomialTensor
102102
@@ -113,28 +113,28 @@ class PolynomialTensor(LinearMixin, GroupMixin, TolerancesMixin, Mapping):
113113
114114
Addition
115115
116-
.. jupyter-execute::
116+
.. code-block:: python
117117
118118
matrix = np.array([[0, 1], [2, 3]], dtype=float)
119119
0.5 * PolynomialTensor({"+-": matrix}) + PolynomialTensor({"+-": matrix})
120120
121121
Operator multiplication
122122
123-
.. jupyter-execute::
123+
.. code-block:: python
124124
125125
tensor = PolynomialTensor({"+-": matrix})
126126
print(tensor @ tensor)
127127
128128
Tensor multiplication
129129
130-
.. jupyter-execute::
130+
.. code-block:: python
131131
132132
print(tensor ^ tensor)
133133
134134
You can also implement more advanced arithmetic via the :meth:`apply` and :meth:`einsum`
135135
methods.
136136
137-
.. jupyter-execute::
137+
.. code-block:: python
138138
139139
print(PolynomialTensor.apply(np.transpose, tensor))
140140
print(PolynomialTensor.apply(np.conjugate, 1j * tensor))
@@ -148,7 +148,7 @@ class PolynomialTensor(LinearMixin, GroupMixin, TolerancesMixin, Mapping):
148148
it needs to support more than 2-dimensional arrays, we rely on the
149149
`sparse <https://sparse.pydata.org/en/stable/index.html>`_ library.
150150
151-
.. jupyter-execute::
151+
.. code-block:: python
152152
153153
import sparse as sp
154154

qiskit_nature/second_q/operators/spin_op.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class SpinOp(SparseLabelOp):
6161
A ``SpinOp`` is initialized with a dictionary, mapping terms to their respective
6262
coefficients. For example:
6363
64-
.. jupyter-execute::
64+
.. code-block:: python
6565
6666
from qiskit_nature.second_q.operators import SpinOp
6767
@@ -72,7 +72,7 @@ class SpinOp(SparseLabelOp):
7272
are :math:`S^x, S^y, S^z` for spin 3/2 system.
7373
The two qutrit Heisenberg model with transverse magnetic field is
7474
75-
.. jupyter-execute::
75+
.. code-block:: python
7676
7777
SpinOp({
7878
"X_0 X_1": -1,
@@ -88,7 +88,7 @@ class SpinOp(SparseLabelOp):
8888
8989
An example using labels with powers would be:
9090
91-
.. jupyter-execute::
91+
.. code-block:: python
9292
9393
from qiskit_nature.second_q.operators import SpinOp
9494
@@ -99,7 +99,7 @@ class SpinOp(SparseLabelOp):
9999
If you have very restricted memory resources available, or would like to avoid the additional
100100
copy, the dictionary will be stored by reference if you disable ``copy`` like so:
101101
102-
.. jupyter-execute::
102+
.. code-block:: python
103103
104104
some_big_data = {
105105
"X_0 Y_0": 1.0,
@@ -133,40 +133,40 @@ class SpinOp(SparseLabelOp):
133133
134134
Addition
135135
136-
.. jupyter-execute::
136+
.. code-block:: python
137137
138138
SpinOp({"X_1": 1}, num_spins=2) + SpinOp({"X_0": 1}, num_spins=2)
139139
140140
Sum
141141
142-
.. jupyter-execute::
142+
.. code-block:: python
143143
144144
sum(SpinOp({label: 1}, num_spins=3) for label in ["X_0", "Z_1", "X_2 Z_2"])
145145
146146
Scalar multiplication
147147
148-
.. jupyter-execute::
148+
.. code-block:: python
149149
150150
0.5 * SpinOp({"X_1": 1}, num_spins=2)
151151
152152
Operator multiplication
153153
154-
.. jupyter-execute::
154+
.. code-block:: python
155155
156156
op1 = SpinOp({"X_0 Z_1": 1}, num_spins=2)
157157
op2 = SpinOp({"Z_0 X_0 X_1": 1}, num_spins=2)
158158
print(op1 @ op2)
159159
160160
Tensor multiplication
161161
162-
.. jupyter-execute::
162+
.. code-block:: python
163163
164164
op = SpinOp({"X_0 Z_1": 1}, num_spins=2)
165165
print(op ^ op)
166166
167167
Adjoint
168168
169-
.. jupyter-execute::
169+
.. code-block:: python
170170
171171
SpinOp({"X_0 Z_1": 1j}, num_spins=2).adjoint()
172172

qiskit_nature/second_q/operators/vibrational_op.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class VibrationalOp(SparseLabelOp):
4949
A ``VibrationalOp`` is initialized with a dictionary, mapping terms to their respective
5050
coefficients:
5151
52-
.. jupyter-execute::
52+
.. code-block:: python
5353
5454
from qiskit_nature.second_q.operators import VibrationalOp
5555
@@ -67,7 +67,7 @@ class VibrationalOp(SparseLabelOp):
6767
If you have very restricted memory resources available, or would like to avoid the additional
6868
copy, the dictionary will be stored by reference if you disable ``copy`` like so:
6969
70-
.. jupyter-execute::
70+
.. code-block:: python
7171
7272
some_big_data = {
7373
"+_0_0 -_0_0": 1.0,
@@ -90,7 +90,7 @@ class VibrationalOp(SparseLabelOp):
9090
If :code:`num_modals` is not provided then the maximum :code:`modal_index` per
9191
mode will determine the :code:`num_modals` for that mode.
9292
93-
.. jupyter-execute::
93+
.. code-block:: python
9494
9595
from qiskit_nature.second_q.operators import VibrationalOp
9696
@@ -112,40 +112,40 @@ class VibrationalOp(SparseLabelOp):
112112
113113
Addition
114114
115-
.. jupyter-execute::
115+
.. code-block:: python
116116
117117
VibrationalOp({"+_1_0": 1}, num_modals=[2, 2]) + VibrationalOp({"+_0_0": 1}, num_modals=[2, 2])
118118
119119
Sum
120120
121-
.. jupyter-execute::
121+
.. code-block:: python
122122
123123
sum(VibrationalOp({label: 1}, num_modals=[1, 1, 1]) for label in ["+_0_0", "-_1_0", "+_2_0 -_2_0"])
124124
125125
Scalar multiplication
126126
127-
.. jupyter-execute::
127+
.. code-block:: python
128128
129129
0.5 * VibrationalOp({"+_1_0": 1}, num_modals=[1, 1])
130130
131131
Operator multiplication
132132
133-
.. jupyter-execute::
133+
.. code-block:: python
134134
135135
op1 = VibrationalOp({"+_0_0 -_1_0": 1}, num_modals=[1, 1])
136136
op2 = VibrationalOp({"-_0_0 +_0_0 +_1_0": 1}, num_modals=[1, 1])
137137
print(op1 @ op2)
138138
139139
Tensor multiplication
140140
141-
.. jupyter-execute::
141+
.. code-block:: python
142142
143143
op = VibrationalOp({"+_0_0 -_1_0": 1}, num_modals=[1, 1])
144144
print(op ^ op)
145145
146146
Adjoint
147147
148-
.. jupyter-execute::
148+
.. code-block:: python
149149
150150
VibrationalOp({"+_0_0 -_1_0": 1j}, num_modals=[1, 1]).adjoint()
151151

0 commit comments

Comments
 (0)