- 
                Notifications
    
You must be signed in to change notification settings  - Fork 138
 
add generation step to openqasm integ tests #406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add generation step to openqasm integ tests #406
Conversation
          Codecov Report
 @@                      Coverage Diff                       @@
##           feature/openqasm_generation      #406    +/-   ##
==============================================================
  Coverage                       100.00%   100.00%            
==============================================================
  Files                               79        79            
  Lines                             5691      5583   -108     
  Branches                           816       780    -36     
==============================================================
- Hits                              5691      5583   -108     
 Continue to review full report at Codecov. 
  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do this for all gate model tests here for better coverage ?
| factors = [] | ||
| use_qubits = iter(target) | ||
| for obs in self._factors: | ||
| obs_target = QubitSet() | ||
| num_qubits = int(np.log2(obs.to_matrix().shape[0])) | ||
| for _ in range(num_qubits): | ||
| obs_target.add(next(use_qubits)) | ||
| factors.append( | ||
| obs.to_ir( | ||
| target=obs_target, | ||
| ir_type=IRType.OPENQASM, | ||
| serialization_properties=serialization_properties, | ||
| ) | ||
| ) | ||
| for obs, targ in zip(self._factors, target) | ||
| ) | ||
| return " @ ".join(factors) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix: this change allows 2q hermitians to consume 2 qubits of the target
| def _to_openqasm(self, serialization_properties: OpenQASMSerializationProperties) -> str: | ||
| if not self.target: | ||
| return "#pragma braket result probability" | ||
| return "#pragma braket result probability all" | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Service does not currently support exclusion of all due to lark restrictions
| result, shots, expected_var, expected_mean, expected_eigs | ||
| ) | ||
| tasks = (circuit,) if not test_program else (circuit, circuit.to_ir(ir_type=IRType.OPENQASM)) | ||
| print(circuit.to_ir(ir_type=IRType.OPENQASM)) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, no
Issue #, if available:
#328
Description of changes:
Add openqasm generation step to openqasm integ tests.
Testing done:
tox -e integ-tests -- -k openqasm
Merge Checklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.General
Tests
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.