Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes some error in the way ZNE options are validated and tested.
Details and comments
Currently, ZNE validation and testing have the following problems:
_validate_zne_noise_factors
method passes in the case the noise factors are the empty list[]
although this is an invalid input, since the initial checkif self.extrapolator and self.noise_factors
considersself.noise_factors
to beFalse
in case it is an empty list.{"resilience": {"zne": {"noise_factors": [1]}}}
thetest_bad_inputs
test succeeds becauseValidationError
is thrown even though the intended error (not enough noise factors) is not tested, since this error is masked by the error of not havingzne_mitigation: True
in the resilience dictionary.These problems are handled in the following manner:
_validate_zne_noise_factors
now never skips. If noise factors or extrapolators are missing, it uses the default values described in the class's file.test_bad_inputs
now usesassertRaisesRegex
with relevant error message for each test case, to avoid passing when irrelevant exceptions are thrown.test_bad_inputs
for the case of empty noise factors list and for the case of missingzne_mitigation: True
.