Skip to content

Commit 86580f0

Browse files
add scipy version dependent results (#336)
1 parent 0703042 commit 86580f0

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

tests/qnn/test_training.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import numpy as np
44
import pytest
5+
from packaging import version
6+
from scipy import __version__ as scipy_version
57

68
from squlearn import Executor
79
from squlearn.observables import SummedPaulis, SinglePauli
@@ -147,8 +149,19 @@ def _build_qnn_setup(self, pqc, ob, test_case: str):
147149
def test_zero_param_ob(self, test_case):
148150
"""Test for zero number of parameters in observable."""
149151

152+
# scipy changed their slsqp implementation in 1.16.0 and we don't want to limit the user to
153+
# a specific scipy
154+
if version.parse(scipy_version) < version.parse("1.16.0"):
155+
regressor_result = np.array(
156+
[0.11503425, 0.10989764, 0.11377155, 0.12618358, 0.14544058]
157+
)
158+
else:
159+
regressor_result = np.array(
160+
[0.11080395, 0.10440662, 0.10877287, 0.12350483, 0.14668292]
161+
)
162+
150163
assert_dict = {
151-
"QNNRegressor": np.array([0.11080395, 0.10440662, 0.10877287, 0.12350483, 0.14668292]),
164+
"QNNRegressor": regressor_result,
152165
"QNNClassifier": np.array([0, 0, 0, 0, 0]),
153166
}
154167
pqc = ChebyshevPQC(2, 1, 1)

0 commit comments

Comments
 (0)