This repository was archived by the owner on Jan 12, 2024. It is now read-only.
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Improve handling of invalid models in ApplySequentialClassifier #268
Open
Description
Describe the bug
Passing an invalid model to ApplySequentialClassifier can causes unexpected and inconsistent behaviors:
- If the index of the target qubit or one of the control qubits used in the ControlledRotation is outside of the
qubits
array, it will cause runtime error (since this is not handled explicitly). - If
ParameterIndex
of the parameter used in the ControlledRotation is outside of the parameters array, the gate will be quietly ignored (this is handled explicitly).
This makes errors fairly hard to find.
Expected behavior
I would expect both these behaviors be handled similarly, ideally by throwing an error "The model is invalid for reason X". For better performance we might want to validate the model closer to the entry points of the library, rather than on each call of ApplySequentialClassifier.