Skip to content

Commit 3faeee5

Browse files
Fix for docplex 2.20 (qiskit-community/qiskit-aqua#1520)
* Fix for docplex 2.20 * fix cvxpy not installed on unit test Co-authored-by: Manoel Marques <[email protected]>
1 parent 114c569 commit 3faeee5

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

test/aqua/test_qsvm.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,19 @@ def test_matrix_psd(self):
244244

245245
feature_map = ZZFeatureMap(feature_dimension=feature_dim, reps=2, entanglement='linear')
246246

247-
with self.assertRaises(DQCPError):
248-
# Sampling noise means that the kernel matrix will not quite be positive
249-
# semi-definite which will cause the optimize svm to fail
250-
backend = BasicAer.get_backend('qasm_simulator')
251-
quantum_instance = QuantumInstance(backend, shots=1024, seed_simulator=seed,
252-
seed_transpiler=seed)
253-
kernel_matrix = QSVM.get_kernel_matrix(quantum_instance, feature_map=feature_map,
254-
x1_vec=training_data, enforce_psd=False)
255-
_ = optimize_svm(kernel_matrix, labels, lambda2=0)
247+
try:
248+
with self.assertRaises(DQCPError):
249+
# Sampling noise means that the kernel matrix will not quite be positive
250+
# semi-definite which will cause the optimize svm to fail
251+
backend = BasicAer.get_backend('qasm_simulator')
252+
quantum_instance = QuantumInstance(backend, shots=1024, seed_simulator=seed,
253+
seed_transpiler=seed)
254+
kernel_matrix = QSVM.get_kernel_matrix(quantum_instance, feature_map=feature_map,
255+
x1_vec=training_data, enforce_psd=False)
256+
_ = optimize_svm(kernel_matrix, labels, lambda2=0)
257+
except MissingOptionalLibraryError as ex:
258+
self.skipTest(str(ex))
259+
return
256260

257261
# This time we enforce that the matrix be positive semi-definite which runs logic to
258262
# make it so.

0 commit comments

Comments
 (0)