Skip to content

Commit 3fb215f

Browse files
committed
added pytests for uspantek quantum 2x2. gives attribute error. have captured that in pytest.
1 parent dae0c76 commit 3fb215f

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

test_oov_no_pair.py

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,55 @@ def test_uspantek_quantum1_yes_expose_val(monkeypatch):
271271
except Exception as ex:
272272
print(ex)
273273
assert type(ex) == KeyError
274-
274+
275+
276+
# quantum2+uspantek
277+
# python classify.py --dataset uspantek --parser BobCatParser --ansatz IQPAnsatz --model14type PennyLaneModel --trainer QuantumTrainer --epochs_train_model1 30 --no_of_training_data_points_to_use 70 --no_of_val_data_points_to_use 30 --max_tokens_per_sent 10
278+
# returns: raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
279+
# AttributeError: 'PennyLaneModel' object has no attribute '_clear_predictions'
280+
281+
def test_uspantek_quantum2_no_expose_val(monkeypatch):
282+
monkeypatch.setattr(sys, 'argv',
283+
['classify.py',
284+
'--dataset', 'uspantek',
285+
'--parser', 'BobCatParser',
286+
'--ansatz', 'IQPAnsatz',
287+
'--model14type', 'PennyLaneModel',
288+
'--trainer', 'QuantumTrainer',
289+
'--epochs_train_model1', '30',
290+
'--no_of_training_data_points_to_use', '70',
291+
'--no_of_val_data_points_to_use', '30',
292+
'--max_tokens_per_sent', '10' ,
293+
])
294+
try:
295+
model4_loss, model4_acc=classify.main()
296+
except Exception as ex:
297+
print(ex)
298+
assert type(ex) == AttributeError
299+
300+
301+
302+
# quantum2+uspantek+yes expose
303+
# python classify.py --dataset uspantek --parser BobCatParser --ansatz IQPAnsatz --model14type PennyLaneModel --trainer QuantumTrainer --epochs_train_model1 30 --no_of_training_data_points_to_use 70 --no_of_val_data_points_to_use 30 --max_tokens_per_sent 10
304+
# returns: raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
305+
# AttributeError: 'PennyLaneModel' object has no attribute '_clear_predictions'
306+
307+
def test_uspantek_quantum2_yes_expose_val(monkeypatch):
308+
monkeypatch.setattr(sys, 'argv',
309+
['classify.py',
310+
'--dataset', 'uspantek',
311+
'--parser', 'BobCatParser',
312+
'--ansatz', 'IQPAnsatz',
313+
'--model14type', 'PennyLaneModel',
314+
'--trainer', 'QuantumTrainer',
315+
'--epochs_train_model1', '30',
316+
'--no_of_training_data_points_to_use', '70',
317+
'--no_of_val_data_points_to_use', '30',
318+
'--max_tokens_per_sent', '10' ,
319+
'--expose_model1_val_during_model_initialization'
320+
])
321+
try:
322+
model4_loss, model4_acc=classify.main()
323+
except Exception as ex:
324+
print(ex)
325+
assert type(ex) == AttributeError

0 commit comments

Comments
 (0)