@@ -244,15 +244,19 @@ def test_matrix_psd(self):
244
244
245
245
feature_map = ZZFeatureMap (feature_dimension = feature_dim , reps = 2 , entanglement = 'linear' )
246
246
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
256
260
257
261
# This time we enforce that the matrix be positive semi-definite which runs logic to
258
262
# make it so.
0 commit comments