Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Commit b1cac81

Browse files
authored
fix: Update license message to 2022 (#24)
1 parent 6b3c511 commit b1cac81

File tree

6 files changed

+84
-52
lines changed

6 files changed

+84
-52
lines changed

docs/conf.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1-
# Configuration file for the Sphinx documentation builder.
1+
# Copyright 2022 Q-CTRL
22
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
Configuration file for the Sphinx documentation builder.
17+
"""
318
# This file only contains a selection of the most common options. For a full
419
# list see the documentation:
520
# https://www.sphinx-doc.org/en/master/usage/configuration.html
@@ -22,7 +37,7 @@
2237
project = package_info['description']
2338
author = ", ".join(package_info['authors'])
2439
release = package_info['version']
25-
copyright = '2019, Q-CTRL <[email protected]>'
40+
copyright = f"{datetime.datetime.now().year}, Q-CTRL <[email protected]>"
2641

2742
# -- General configuration ---------------------------------------------------
2843

docs/licence.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Licence
22
=======
33

4-
Copyright 2019 Q-CTRL
4+
Copyright 2022 Q-CTRL
55

66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.

qctrlpyquil/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 Q-CTRL
1+
# Copyright 2022 Q-CTRL
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -22,4 +22,4 @@
2222

2323
from .program import convert_dds_to_pyquil_program
2424

25-
__all__ = ['convert_dds_to_pyquil_program']
25+
__all__ = ["convert_dds_to_pyquil_program"]

qctrlpyquil/program.py

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 Q-CTRL
1+
# Copyright 2022 Q-CTRL
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -31,12 +31,14 @@
3131
FIX_DURATION_UNITARY = "fixed duration unitary"
3232
INSTANT_UNITARY = "instant unitary"
3333

34+
3435
def convert_dds_to_pyquil_program(
35-
dynamic_decoupling_sequence,
36-
target_qubits=None,
37-
gate_time=0.1,
38-
add_measurement=True,
39-
algorithm=INSTANT_UNITARY):
36+
dynamic_decoupling_sequence,
37+
target_qubits=None,
38+
gate_time=0.1,
39+
add_measurement=True,
40+
algorithm=INSTANT_UNITARY,
41+
):
4042

4143
"""Converts a Dynamic Decoupling Sequence into quantum program
4244
as defined in pyQuil.
@@ -90,32 +92,41 @@ def convert_dds_to_pyquil_program(
9092
"""
9193

9294
if dynamic_decoupling_sequence is None:
93-
raise ArgumentsValueError('No dynamic decoupling sequence provided.',
94-
{'dynamic_decoupling_sequence': dynamic_decoupling_sequence})
95+
raise ArgumentsValueError(
96+
"No dynamic decoupling sequence provided.",
97+
{"dynamic_decoupling_sequence": dynamic_decoupling_sequence},
98+
)
9599

96100
if not isinstance(dynamic_decoupling_sequence, DynamicDecouplingSequence):
97-
raise ArgumentsValueError('Dynamical decoupling sequence is not recognized.'
98-
'Expected DynamicDecouplingSequence instance',
99-
{'type(dynamic_decoupling_sequence)':
100-
type(dynamic_decoupling_sequence)})
101+
raise ArgumentsValueError(
102+
"Dynamical decoupling sequence is not recognized."
103+
"Expected DynamicDecouplingSequence instance",
104+
{"type(dynamic_decoupling_sequence)": type(dynamic_decoupling_sequence)},
105+
)
101106

102107
target_qubits = target_qubits or [0]
103108

104109
if gate_time <= 0:
105110
raise ArgumentsValueError(
106-
'Time delay of identity gate must be greater than zero.',
107-
{'gate_time': gate_time})
111+
"Time delay of identity gate must be greater than zero.",
112+
{"gate_time": gate_time},
113+
)
108114

109115
if np.any(target_qubits) < 0:
110116
raise ArgumentsValueError(
111-
'Every target qubits index must be non-negative.',
112-
{'target_qubits': target_qubits})
117+
"Every target qubits index must be non-negative.",
118+
{"target_qubits": target_qubits},
119+
)
113120

114121
if algorithm not in [FIX_DURATION_UNITARY, INSTANT_UNITARY]:
115-
raise ArgumentsValueError('Algorithm must be one of {} or {}'.format(
116-
INSTANT_UNITARY, FIX_DURATION_UNITARY), {'algorithm': algorithm})
122+
raise ArgumentsValueError(
123+
"Algorithm must be one of {} or {}".format(
124+
INSTANT_UNITARY, FIX_DURATION_UNITARY
125+
),
126+
{"algorithm": algorithm},
127+
)
117128

118-
unitary_time = 0.
129+
unitary_time = 0.0
119130
if algorithm == FIX_DURATION_UNITARY:
120131
unitary_time = gate_time
121132

@@ -127,11 +138,14 @@ def convert_dds_to_pyquil_program(
127138

128139
time_covered = 0
129140
program = Program()
130-
program += Pragma('PRESERVE_BLOCK')
141+
program += Pragma("PRESERVE_BLOCK")
131142

132143
for offset, rabi_rotation, azimuthal_angle, detuning_rotation in zip(
133-
list(offsets), list(rabi_rotations),
134-
list(azimuthal_angles), list(detuning_rotations)):
144+
list(offsets),
145+
list(rabi_rotations),
146+
list(azimuthal_angles),
147+
list(detuning_rotations),
148+
):
135149

136150
offset_distance = offset - time_covered
137151

@@ -143,10 +157,13 @@ def convert_dds_to_pyquil_program(
143157
"Offsets cannot be placed properly. Spacing between the rotations"
144158
"is smaller than the time required to perform the rotation. Provide"
145159
"a longer dynamic decoupling sequence or shorted gate time.",
146-
{'dynamic_decoupling_sequence': dynamic_decoupling_sequence,
147-
'gate_time': gate_time})
160+
{
161+
"dynamic_decoupling_sequence": dynamic_decoupling_sequence,
162+
"gate_time": gate_time,
163+
},
164+
)
148165

149-
while (time_covered+gate_time) <= offset:
166+
while (time_covered + gate_time) <= offset:
150167
for qubit in target_qubits:
151168
program += I(qubit)
152169
time_covered += gate_time
@@ -160,14 +177,16 @@ def convert_dds_to_pyquil_program(
160177
nonzero_pulse_counts = 3 - np.sum(zero_pulses)
161178
if nonzero_pulse_counts > 1:
162179
raise ArgumentsValueError(
163-
'Open Controls support a sequence with one '
164-
'valid rotation at any offset. Found a sequence '
165-
'with multiple rotation operations at an offset.',
166-
{'dynamic_decoupling_sequence': dynamic_decoupling_sequence},
167-
extras={'offset': offset,
168-
'rabi_rotation': rabi_rotation,
169-
'azimuthal_angle': azimuthal_angle,
170-
'detuning_rotation': detuning_rotation}
180+
"Open Controls support a sequence with one "
181+
"valid rotation at any offset. Found a sequence "
182+
"with multiple rotation operations at an offset.",
183+
{"dynamic_decoupling_sequence": dynamic_decoupling_sequence},
184+
extras={
185+
"offset": offset,
186+
"rabi_rotation": rabi_rotation,
187+
"azimuthal_angle": azimuthal_angle,
188+
"detuning_rotation": detuning_rotation,
189+
},
171190
)
172191

173192
for qubit in target_qubits:
@@ -178,17 +197,16 @@ def convert_dds_to_pyquil_program(
178197
program += RX(rotations[0], qubit)
179198
elif not np.isclose(rotations[1], 0.0):
180199
program += RY(rotations[1], qubit)
181-
elif not np.isclose(rotations[2], 0.):
200+
elif not np.isclose(rotations[2], 0.0):
182201
program += RZ(rotations[2], qubit)
183202

184203
time_covered = offset + unitary_time
185204

186205
if add_measurement:
187-
readout = program.declare('ro', 'BIT', len(target_qubits))
206+
readout = program.declare("ro", "BIT", len(target_qubits))
188207
for idx, qubit in enumerate(target_qubits):
189208
program += MEASURE(qubit, readout[idx])
190209

191-
program += Pragma('END_PRESERVE_BLOCK')
210+
program += Pragma("END_PRESERVE_BLOCK")
192211

193212
return program
194-

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 Q-CTRL
1+
# Copyright 2022 Q-CTRL
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

tests/test_pyquil_sequence.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 Q-CTRL
1+
# Copyright 2022 Q-CTRL
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727

2828
from qctrlpyquil import convert_dds_to_pyquil_program
2929

30+
3031
def test_pyquil_program():
3132

3233
"""Tests if the Dynamic Decoupling Sequence gives rise to Identity
@@ -43,17 +44,15 @@ def test_pyquil_program():
4344
offsets=_offsets,
4445
rabi_rotations=_rabi_rotations,
4546
azimuthal_angles=_azimuthal_angles,
46-
detuning_rotations=_detuning_rotations)
47+
detuning_rotations=_detuning_rotations,
48+
)
4749

48-
program = convert_dds_to_pyquil_program(
49-
sequence,
50-
[0],
51-
gate_time=1e-6)
50+
program = convert_dds_to_pyquil_program(sequence, [0], gate_time=1e-6)
5251

5352
assert len(program) == 13
5453
assert program[0] == Pragma("PRESERVE_BLOCK")
5554
assert program[-1] == Pragma("END_PRESERVE_BLOCK")
56-
assert program[1] == RX(np.pi/2, 0)
55+
assert program[1] == RX(np.pi / 2, 0)
5756
assert program[2] == I(0)
5857
assert program[3] == RX(np.pi / 2, 0)
5958
assert program[4] == I(0)
@@ -63,6 +62,6 @@ def test_pyquil_program():
6362
assert program[8] == I(0)
6463
assert program[9] == RX(np.pi / 2, 0)
6564

66-
if __name__ == '__main__':
65+
66+
if __name__ == "__main__":
6767
test_pyquil_program()
68-

0 commit comments

Comments
 (0)