Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Commit

Permalink
fix cvxpy not installed on unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
manoelmarques committed Feb 4, 2021
1 parent 9162ff9 commit b4eb0dc
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions test/aqua/test_qsvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,19 @@ def test_matrix_psd(self):

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

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

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

0 comments on commit b4eb0dc

Please sign in to comment.