Skip to content

Commit 3208a84

Browse files
authored
Merge pull request #163 from q-optimize/release/1.4
Release/1.4 Maintenance updates to code quality and implementation along with some useful utility functions and example notebooks.
2 parents dcdb2be + 435ec20 commit 3208a84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+4005
-566
lines changed

.github/workflows/build_package.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Python Package Build
1+
name: Build and Test
22

33
on:
44
push:
@@ -8,12 +8,12 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11-
build:
11+
build-and-test:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
1515
os: [ubuntu-20.04, ubuntu-18.04, macos-latest, windows-latest]
16-
python-version: [3.6, 3.7, 3.8, 3.9]
16+
python-version: [3.7, 3.8, 3.9]
1717
env:
1818
OS: ${{ matrix.os }}
1919
PYTHON: ${{ matrix.python-version }}

.github/workflows/integration_test.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/nightly_pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
strategy:
5050
matrix:
5151
os: [ubuntu-20.04, ubuntu-18.04, macos-latest, windows-latest]
52-
python-version: [3.6, 3.7, 3.8, 3.9]
52+
python-version: [3.7, 3.8, 3.9]
5353
env:
5454
OS: ${{ matrix.os }}
5555
PYTHON: ${{ matrix.python-version }}

.github/workflows/publish_pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
strategy:
4646
matrix:
4747
os: [ubuntu-20.04, ubuntu-18.04, macos-latest, windows-latest]
48-
python-version: [3.6, 3.7, 3.8, 3.9]
48+
python-version: [3.7, 3.8, 3.9]
4949
env:
5050
OS: ${{ matrix.os }}
5151
PYTHON: ${{ matrix.python-version }}

CHANGELOG.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ This Changelog tracks all past changes to this project as well as details about
99
- `fixed` for any bug fixes.
1010
- `security` in case of vulnerabilities.
1111

12+
## Version `1.4` - 23 Dec 2021
13+
14+
### Summary
15+
16+
Maintenance updates to code quality and implementation along with some useful utility functions and example notebooks.
17+
18+
### Details
19+
20+
- `added` experimental support for Runge Kutta 4 solving of EOM #144
21+
- `changed` the experiment and model classes for handling different propagation methods #144
22+
- `changed` The generator now can handle any list of devices that forms a directed graph #129
23+
- `removed` official support for Python 3.6 #156
24+
- `added` a method to HJSON dump current parameter values #149
25+
- `added` example for the log reader CLI #137
26+
- `added` human readable saving of current best point for the optimizer #140
27+
- `fixed` handling of anharmonicity in transmons with two levels #146
28+
- `added` an example notebook with entangling two-qubit gates #154
29+
- `fixed` Broken State Fidelity #135
30+
1231
## Version `1.3` - 20 Jul 2021
1332

1433
### Summary
@@ -117,4 +136,4 @@ This is the first major and properly packaged release of the `c3-toolset` librar
117136
- `added`, `fixed` Compatibility with Windows and MacOS
118137
- `added` Better Examples and Docs
119138
- `added` pip installation configs
120-
- `added` pip-test deployment github actions
139+
- `added` pip-test deployment github actions

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ We use the [CHANGELOG.md](CHANGELOG.md) as a living document that not only recor
261261

262262
## Continuous Integration Checks
263263

264-
As previously discussed, tests are an inherent part of good code. All Pull Requests made to the repository are automatically tested on Windows, MacOS and Ubuntu with Python 3.6, 3.7, 3.8 and 3.9, which come up in the PR as `Checks`, notifying you whenever a particular check is failing on any platform. Except the `Code Complexity`, all checks should be passing for your PR to be ready for review/merge. The `Codecov` bot will also comment on the PR with a report on the change in the test coverage for that particular PR. If your PR reduces the overall test coverage of the codebase, it is not yet ready and you need to add more tests.
264+
As previously discussed, tests are an inherent part of good code. All Pull Requests made to the repository are automatically tested on Windows, MacOS and Ubuntu with Python 3.7, 3.8 and 3.9, which come up in the PR as `Checks`, notifying you whenever a particular check is failing on any platform. Except the `Code Complexity`, all checks should be passing for your PR to be ready for review/merge. The `Codecov` bot will also comment on the PR with a report on the change in the test coverage for that particular PR. If your PR reduces the overall test coverage of the codebase, it is not yet ready and you need to add more tests.
265265

266266
## Contributor License Agreement
267267

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![codecov](https://codecov.io/gh/q-optimize/c3/branch/dev/graph/badge.svg)](https://codecov.io/gh/q-optimize/c3)
44
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/q-optimize/c3.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/q-optimize/c3/context:python)
55
<a href="https://codeclimate.com/github/q-optimize/c3/maintainability"><img src="https://api.codeclimate.com/v1/badges/a090831b106f863dc223/maintainability" /></a>
6+
[![Build and Test](https://github.com/q-optimize/c3/actions/workflows/build_package.yml/badge.svg)](https://github.com/q-optimize/c3/actions/workflows/build_package.yml)
67
[![Documentation Status](https://readthedocs.org/projects/c3-toolset/badge/?version=latest)](https://c3-toolset.readthedocs.io/en/latest/?badge=latest)
78
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
89
[![PyPI version fury.io](https://badge.fury.io/py/c3-toolset.svg)](https://pypi.python.org/pypi/c3-toolset/)
@@ -38,3 +39,20 @@ Examples are available in the `examples/` directory and can also be run online u
3839
If you wish to contribute, please check out the issues tab and also the `CONTRIBUTING.md` for useful resources.
3940

4041
The source code is available on Github at [https://github.com/q-optimize/c3](https://github.com/q-optimize/c3).
42+
43+
## Citation
44+
45+
If you use `c3-toolset` in your research, please cite it as below:
46+
47+
```
48+
@article{Wittler2021,
49+
title={Integrated Tool Set for Control, Calibration, and Characterization of Quantum Devices Applied to Superconducting Qubits},
50+
volume={15},
51+
DOI={10.1103/physrevapplied.15.034080},
52+
number={3},
53+
journal={Physical Review Applied},
54+
author={Wittler, Nicolas and Roy, Federico and Pack, Kevin and Werninghaus, Max and Saha Roy, Anurag and Egger, Daniel J. and Filipp, Stefan and Wilhelm, Frank K. and Machnes, Shai},
55+
year={2021},
56+
month={Mar}
57+
}
58+
```

c3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.3"
1+
__version__ = "1.4"

c3/c3objs.py

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -123,57 +123,57 @@ def asdict(self) -> dict:
123123

124124
def __add__(self, other):
125125
out_val = copy.deepcopy(self)
126-
out_val.set_value(self.get_value() + other, extend_bounds=True)
126+
out_val._set_value_extend(self.get_value() + other)
127127
return out_val
128128

129129
def __radd__(self, other):
130130
out_val = copy.deepcopy(self)
131-
out_val.set_value(self.get_value() + other, extend_bounds=True)
131+
out_val._set_value_extend(self.get_value() + other)
132132
return out_val
133133

134134
def __sub__(self, other):
135135
out_val = copy.deepcopy(self)
136-
out_val.set_value(self.get_value() - other, extend_bounds=True)
136+
out_val._set_value_extend(self.get_value() - other)
137137
return out_val
138138

139139
def __rsub__(self, other):
140140
out_val = copy.deepcopy(self)
141-
out_val.set_value(other - self.get_value(), extend_bounds=True)
141+
out_val._set_value_extend(other - self.get_value())
142142
return out_val
143143

144144
def __mul__(self, other):
145145
out_val = copy.deepcopy(self)
146-
out_val.set_value(self.get_value() * other, extend_bounds=True)
146+
out_val._set_value_extend(self.get_value() * other)
147147
return out_val
148148

149149
def __rmul__(self, other):
150150
out_val = copy.deepcopy(self)
151-
out_val.set_value(self.get_value() * other, extend_bounds=True)
151+
out_val._set_value_extend(self.get_value() * other)
152152
return out_val
153153

154154
def __pow__(self, other):
155155
out_val = copy.deepcopy(self)
156-
out_val.set_value(self.get_value() ** other, extend_bounds=True)
156+
out_val._set_value_extend(self.get_value() ** other)
157157
return out_val
158158

159159
def __rpow__(self, other):
160160
out_val = copy.deepcopy(self)
161-
out_val.set_value(other ** self.get_value(), extend_bounds=True)
161+
out_val._set_value_extend(other ** self.get_value())
162162
return out_val
163163

164164
def __truediv__(self, other):
165165
out_val = copy.deepcopy(self)
166-
out_val.set_value(self.get_value() / other, extend_bounds=True)
166+
out_val._set_value_extend(self.get_value() / other)
167167
return out_val
168168

169169
def __rtruediv__(self, other):
170170
out_val = copy.deepcopy(self)
171-
out_val.set_value(other / self.get_value(), extend_bounds=True)
171+
out_val._set_value_extend(other / self.get_value())
172172
return out_val
173173

174174
def __mod__(self, other):
175175
out_val = copy.deepcopy(self)
176-
out_val.set_value(self.get_value() % other, extend_bounds=True)
176+
out_val._set_value_extend(self.get_value() % other)
177177
return out_val
178178

179179
def __lt__(self, other):
@@ -253,7 +253,13 @@ def get_value(self, val: tf.float64 = None, dtype: tf.dtypes = None) -> tf.Tenso
253253
value = self.scale * (val + 1) / 2 + self.offset
254254
return tf.cast(value, dtype)
255255

256-
def set_value(self, val, extend_bounds=False) -> None:
256+
def set_value(self, val, extend_bounds=False):
257+
if extend_bounds:
258+
self._set_value_extend(val)
259+
else:
260+
self._set_value(val)
261+
262+
def _set_value(self, val) -> None:
257263
"""Set the value of this quantity as tensorflow. Value needs to be
258264
within specified min and max."""
259265
# setting can be numpyish
@@ -264,25 +270,25 @@ def set_value(self, val, extend_bounds=False) -> None:
264270

265271
tmp = 2 * (val * self.pref - self.offset) / self.scale - 1
266272

267-
if extend_bounds and tf.math.abs(tmp) > 1:
268-
min_val, max_val = self.get_limits()
269-
# Extra bounds included to not be directly at border due to differentiability
270-
minmax = [val * 0.9, val * 1.1, min_val, max_val]
271-
min_val = tf.math.reduce_min(minmax)
272-
max_val = tf.math.reduce_max(minmax)
273-
self.set_limits(min_val, max_val)
274-
tmp = 2 * (val * self.pref - self.offset) / self.scale - 1
275-
276-
tf.debugging.assert_less_equal(
277-
tf.math.abs(tmp),
278-
tf.constant(1.0, tf.float64),
279-
f"Value {val.numpy()}{self.unit} out of bounds for quantity with "
280-
f"min_val: {num3str(self.get_limits()[0])}{self.unit} and "
281-
f"max_val: {num3str(self.get_limits()[1])}{self.unit}",
282-
)
273+
if np.any(tf.math.abs(tmp) > tf.constant(1.0, tf.float64)):
274+
raise Exception(
275+
f"Value {val.numpy()}{self.unit} out of bounds for quantity with "
276+
f"min_val: {num3str(self.get_limits()[0])}{self.unit} and "
277+
f"max_val: {num3str(self.get_limits()[1])}{self.unit}",
278+
)
283279

284280
self.value = tf.cast(tmp, tf.float64)
285281

282+
def _set_value_extend(self, val) -> None:
283+
"""Set the value of this quantity as tensorflow. If needed, limits will be extended."""
284+
min_val, max_val = self.get_limits()
285+
# Extra bounds included to not be directly at border due to differentiability
286+
minmax = [val * 0.9, val * 1.1, min_val, max_val]
287+
min_val = tf.math.reduce_min(minmax)
288+
max_val = tf.math.reduce_max(minmax)
289+
self.set_limits(min_val, max_val)
290+
self._set_value(val)
291+
286292
def get_opt_value(self) -> np.ndarray:
287293
"""Get an optimizer friendly representation of the value."""
288294
return self.value.numpy().flatten()

0 commit comments

Comments
 (0)