Skip to content

Commit eb89d6b

Browse files
authored
Update stable/0.3 for dependency updates (#163)
1 parent 259c259 commit eb89d6b

File tree

8 files changed

+43
-29
lines changed

8 files changed

+43
-29
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# The short X.Y version
2626
version = ''
2727
# The full version, including alpha/beta/rc tags
28-
release = '0.3.1'
28+
release = '0.3.2'
2929

3030
extensions = [
3131
'sphinx.ext.napoleon',

qiskit_dynamics/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.1
1+
0.3.2

qiskit_dynamics/dispatch/backends/jax.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222

2323
JAX_TYPES = (DeviceArray, Tracer, JaxprTracer, JVPTracer)
2424

25+
try:
26+
# This class was introduced in 0.4.0
27+
from jax import Array
28+
29+
JAX_TYPES += (Array,)
30+
except ImportError:
31+
pass
32+
2533
try:
2634
# This class is not in older versions of Jax
2735
from jax.interpreters.partial_eval import DynamicJaxprTracer
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
upgrade:
3+
- |
4+
The ``jax.Array`` class has been added to the dispatcher for compatibility with JAX 0.4.0.

test/dynamics/models/test_generator_model.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
#
33
# (C) Copyright IBM 2020.
44
#
5-
# This code is licensed under the Apache License, Version 2.0. You may
6-
# obtain a copy of this license in the LICENSE.txt file in the root directory
7-
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
5+
# This code is licensed under the Apache License, Version 2.0. You may obtain a copy of this license
6+
# in the LICENSE.txt file in the root directory of this source tree or at
7+
# http://www.apache.org/licenses/LICENSE-2.0.
88
#
9-
# Any modifications or derivative works of this code must retain this
10-
# copyright notice, and modified files need to carry a notice indicating
11-
# that they have been altered from the originals.
9+
# Any modifications or derivative works of this code must retain this copyright notice, and modified
10+
# files need to carry a notice indicating that they have been altered from the originals.
1211
# pylint: disable=invalid-name
1312

1413
"""Tests for generator_models.py. """
@@ -757,29 +756,31 @@ def test_array_inputs_pseudo_random(self):
757756
old_frame = rng.uniform(low=-b, high=b, size=(dim, dim)) + 1j * rng.uniform(
758757
low=-b, high=b, size=(dim, dim)
759758
)
760-
old_frame = old_frame - old_frame.conj().transpose()
759+
old_frame = RotatingFrame(old_frame - old_frame.conj().transpose())
760+
761761
new_frame = rng.uniform(low=-b, high=b, size=(dim, dim)) + 1j * rng.uniform(
762762
low=-b, high=b, size=(dim, dim)
763763
)
764-
new_frame = new_frame - new_frame.conj().transpose()
764+
new_frame = RotatingFrame(new_frame - new_frame.conj().transpose())
765765

766766
out_static = transfer_static_operator_between_frames(
767-
Array(static_operator), new_frame=Array(new_frame), old_frame=Array(old_frame)
767+
Array(static_operator), new_frame=new_frame, old_frame=old_frame
768768
)
769769
out_operators = transfer_operators_between_frames(
770-
Array(operators), new_frame=Array(new_frame), old_frame=Array(old_frame)
770+
Array(operators), new_frame=new_frame, old_frame=old_frame
771771
)
772772

773773
self.assertTrue(isinstance(out_static, (np.ndarray, Array)))
774774
self.assertTrue(isinstance(out_operators, (np.ndarray, Array)))
775775

776-
_, U = wrap(np.linalg.eigh)(1j * old_frame)
777-
_, V = wrap(np.linalg.eigh)(1j * new_frame)
778-
Uadj = U.conj().transpose()
779-
Vadj = V.conj().transpose()
780-
781-
expected_static = Vadj @ ((U @ static_operator @ Uadj + old_frame) - new_frame) @ V
782-
expected_operators = Vadj @ (U @ operators @ Uadj) @ V
776+
expected_static = new_frame.operator_into_frame_basis(
777+
(old_frame.operator_out_of_frame_basis(static_operator) + old_frame.frame_operator)
778+
- new_frame.frame_operator
779+
)
780+
expected_operators = [
781+
new_frame.operator_into_frame_basis(old_frame.operator_out_of_frame_basis(op))
782+
for op in operators
783+
]
783784

784785
self.assertAllClose(out_static, expected_static)
785786
self.assertAllClose(out_operators, expected_operators)

test/dynamics/solvers/test_lanczos.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
#
33
# (C) Copyright IBM 2022.
44
#
5-
# This code is licensed under the Apache License, Version 2.0. You may
6-
# obtain a copy of this license in the LICENSE.txt file in the root directory
7-
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
5+
# This code is licensed under the Apache License, Version 2.0. You may obtain a copy of this license
6+
# in the LICENSE.txt file in the root directory of this source tree or at
7+
# http://www.apache.org/licenses/LICENSE-2.0.
88
#
9-
# Any modifications or derivative works of this code must retain this
10-
# copyright notice, and modified files need to carry a notice indicating
11-
# that they have been altered from the originals.
9+
# Any modifications or derivative works of this code must retain this copyright notice, and modified
10+
# files need to carry a notice indicating that they have been altered from the originals.
1211
# pylint: disable=invalid-name
1312

1413
"""
@@ -64,7 +63,9 @@ def test_ground_state(self):
6463
eigen_vectors_l = q_basis @ eigen_vectors_t
6564
eigen_values_np, eigen_vectors_np = np.linalg.eigh(self.rand_op)
6665

67-
self.assertAllClose(eigen_vectors_np[:, 0], eigen_vectors_l[:, 0])
66+
# test overlap is 1.
67+
overlap = np.abs(np.sum(eigen_vectors_np[:, 0].conj() * eigen_vectors_l[:, 0]))
68+
self.assertAllClose(overlap, 1.0)
6869
self.assertAllClose(eigen_values_np[0], eigen_values_l[0])
6970

7071
def test_expm(self):

test/dynamics/solvers/test_solver_classes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ def test_two_channel_SuperOp_simulation(self, model):
997997
y0=SuperOp(np.eye(4, dtype=complex)),
998998
schedules=sched,
999999
signals=signals,
1000-
test_tol=1e-9,
1000+
test_tol=1e-8,
10011001
atol=1e-12,
10021002
rtol=1e-12,
10031003
)

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
2-
minversion = 2.1
2+
minversion = 3.3.0
33
envlist = py39,py38,py37,py310,lint
4-
skipsdist = True
4+
isolated_build = true
55

66
[testenv]
77
usedevelop = True

0 commit comments

Comments
 (0)