Skip to content

Commit 48b7917

Browse files
nwittlerlazyoracle
andauthored
Update dependencies (#243)
* Max version for tf probability * Update workflow to python 3.10 * Bump tf versions * Checking properties of tf objs compatible with tf 2.15 * Fix for qiskit? * Remove depricated use of int * Deprecated use of complex removed * Update requirements * Python version as string * Reblacked, fixed types * Interface to keras SGD * try to fix missing qiskit-aer dep --------- Co-authored-by: lazyoracle <contact@anuragsaharoy.me>
1 parent 57fc8d9 commit 48b7917

20 files changed

+40
-50
lines changed

.github/workflows/build_package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
os: [ubuntu-latest, macos-latest, windows-latest]
16-
python-version: [3.9]
16+
python-version: ['3.10']
1717
env:
1818
OS: ${{ matrix.os }}
1919
PYTHON: ${{ matrix.python-version }}

.github/workflows/coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: [3.9]
16+
python-version: ['3.10']
1717
env:
1818
OS: 'ubuntu-latest'
19-
PYTHON: '3.9'
19+
PYTHON: '3.10'
2020
steps:
2121
- uses: actions/checkout@v2
2222
- name: Set up Python ${{ matrix.python-version }}

.github/workflows/format_lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: [3.9]
16+
python-version: ['3.10']
1717
env:
1818
OS: 'ubuntu-latest'
19-
PYTHON: '3.9'
19+
PYTHON: '3.10'
2020
steps:
2121
- uses: actions/checkout@v2
2222
- name: Set up Python ${{ matrix.python-version }}

.github/workflows/nightly_pypi.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
- uses: actions/checkout@master
1212
with:
1313
ref: 'dev'
14-
- name: Set up Python 3.9
14+
- name: Set up Python 3.10
1515
uses: actions/setup-python@v1
1616
with:
17-
python-version: 3.9
17+
python-version: 3.10
1818
- name : Install Prerequisites
1919
run : |
2020
sudo apt-add-repository universe
@@ -49,7 +49,7 @@ jobs:
4949
strategy:
5050
matrix:
5151
os: [ubuntu-latest, macos-latest, windows-latest]
52-
python-version: [3.9]
52+
python-version: ['3.10']
5353
env:
5454
OS: ${{ matrix.os }}
5555
PYTHON: ${{ matrix.python-version }}

.github/workflows/notebook_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
os: [ubuntu-latest]
16-
python-version: [3.9]
16+
python-version: ['3.10']
1717
env:
1818
OS: ${{ matrix.os }}
1919
PYTHON: ${{ matrix.python-version }}

.github/workflows/publish_pypi.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@master
13-
- name: Set up Python 3.9
13+
- name: Set up Python '3.10'
1414
uses: actions/setup-python@v1
1515
with:
16-
python-version: 3.9
16+
python-version: '3.10'
1717
- name : Install Prerequisites
1818
run : |
1919
sudo apt-add-repository universe
@@ -45,7 +45,7 @@ jobs:
4545
strategy:
4646
matrix:
4747
os: [ubuntu-latest, macos-latest, windows-latest]
48-
python-version: [3.9]
48+
python-version: ['3.10']
4949
env:
5050
OS: ${{ matrix.os }}
5151
PYTHON: ${{ matrix.python-version }}

c3/c3objs.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def __init__(self, name, desc="", comment="", params=None):
3737
if params:
3838
for pname, par in params.items():
3939
# TODO params here should be the dict representation only
40-
if isinstance(par, Quantity):
41-
self.params[pname] = par
42-
else:
40+
if isinstance(par, dict):
4341
self.params[pname] = Quantity(**par)
42+
else:
43+
self.params[pname] = par
4444

4545
def __str__(self) -> str:
4646
return hjson.dumps(self.asdict(), default=hjson_encode)
@@ -276,10 +276,7 @@ def _set_value(self, val) -> None:
276276
"""Set the value of this quantity as tensorflow. Value needs to be
277277
within specified min and max."""
278278
# setting can be numpyish
279-
if isinstance(val, ops.EagerTensor) or isinstance(val, ops.Tensor):
280-
val = tf.cast(val, tf.float64)
281-
else:
282-
val = tf.constant(val, tf.float64)
279+
val = tf.constant(val, tf.float64)
283280

284281
tmp = (
285282
2 * (tf.reshape(val, self.shape) * self.pref - self.offset) / self.scale - 1

c3/generator/devices.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ def __init__(self, **props):
10201020

10211021
def get_noise(self, sig):
10221022
noise_amp = self.params["noise_amp"].get_value().numpy()
1023-
bfl_num = np.int(self.params["bfl_num"].get_value().numpy())
1023+
bfl_num = int(self.params["bfl_num"].get_value().numpy())
10241024
noise = []
10251025
bfls = 2 * np.random.randint(2, size=bfl_num) - 1
10261026
num_steps = len(sig)

c3/libraries/algorithms.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ def tf_fun():
284284

285285
opt_sgd = tf.keras.optimizers.SGD(learning_rate=learning_rate, momentum=momentum)
286286

287-
for _ in range(iters):
288-
step_count = opt_sgd.minimize(tf_fun, [var])
289-
print(f"epoch {step_count.numpy()}: func_value: {tf_fun()}")
287+
for ii in range(iters):
288+
opt_sgd.minimize(tf_fun, [var])
289+
print(f"iter {ii}: func_value: {tf_fun()}")
290290

291291
result = OptimizeResult(x=var.numpy(), success=True)
292292
return result
@@ -524,7 +524,6 @@ def cmaes(x_init, fun=None, fun_grad=None, grad_lookup=None, options={}):
524524
es = cma.CMAEvolutionStrategy(x_init, spread, settings)
525525
iter = 0
526526
while not es.stop():
527-
528527
if shrunk_check:
529528
sigmas.append(es.sigma)
530529
if iter > sigma_conv:
@@ -627,7 +626,6 @@ def gcmaes(x_init, fun=None, fun_grad=None, grad_lookup=None, options={}):
627626
es = cma.CMAEvolutionStrategy(x_init, spread, settings)
628627
iter = 0
629628
while not es.stop():
630-
631629
if shrinked_check:
632630
sigmas.append(es.sigma)
633631
if iter > sigma_conv:

c3/libraries/propagation.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,6 @@ def tf_expm_dynamic(A, acc=1e-5):
688688
def ode_solver(
689689
model: Model, gen: Generator, instr: Instruction, init_state, solver, step_function
690690
) -> Dict:
691-
692691
signal = gen.generate_signals(instr)
693692

694693
if model.lindbladian:
@@ -726,7 +725,6 @@ def ode_solver(
726725
def ode_solver_final_state(
727726
model: Model, gen: Generator, instr: Instruction, init_state, solver, step_function
728727
) -> Dict:
729-
730728
signal = gen.generate_signals(instr)
731729

732730
if model.lindbladian:

0 commit comments

Comments
 (0)