Convert BraketSimulator.Circuit to Braket.Circuit#42
Open
contra-bit wants to merge 2 commits into
Open
Conversation
kshyatt-aws
reviewed
Aug 21, 2024
54b700b to
2c901f7
Compare
2c901f7 to
3ccdce9
Compare
kshyatt-aws
reviewed
Aug 27, 2024
kshyatt-aws
reviewed
Sep 27, 2024
|
|
||
| function Base.convert(::Type{Braket.Circuit}, c::BraketSimulator.Circuit) | ||
| ixs = [convert(Braket.Instruction, ix) for ix in c.instructions] | ||
| rts = isempty(c.result_types) ? Braket.Result[] : [convert(Braket.Result, rt) for rt in c.result_types] |
Contributor
There was a problem hiding this comment.
I don't think you need the isempty check here,
rts = Braket.Result[convert(Braket.Result, rt) for rt in c.result_types] should be enough.
kshyatt-aws
reviewed
Sep 27, 2024
| ixs = [convert(Braket.Instruction, ix) for ix in c.instructions] | ||
| rts = isempty(c.result_types) ? Braket.Result[] : [convert(Braket.Result, rt) for rt in c.result_types] | ||
| brs = [convert(Braket.Instruction, ix) for ix in c.basis_rotation_instructions] | ||
| Braket.Circuit(Braket.Moments(), ixs, rts, brs) |
Contributor
There was a problem hiding this comment.
It might be better to use add_instruction! for the instructions to populate the moments, so that the returned Braket.Circuit can have noise models applied correctly.
kshyatt-aws
reviewed
Sep 27, 2024
| end | ||
| end | ||
|
|
||
| @testset "BraketSimulator to Braket Conversion" begin |
Contributor
There was a problem hiding this comment.
These are great but it might be good to have a couple smaller tests too, for example covering the non-empty results situation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
*Issue #38
Description of changes:
Convert BraketSimulator.Circuit to Braket.Circuit
Testing done:
Added base test for conversion
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.