fix: Implicit string concatenation in a list#1228
Open
odaysec wants to merge 1 commit intoamazon-braket:mainfrom
Open
fix: Implicit string concatenation in a list#1228odaysec wants to merge 1 commit intoamazon-braket:mainfrom
odaysec wants to merge 1 commit intoamazon-braket:mainfrom
Conversation
Contributor
|
@odaysec thank you for the contribution! Could you say more about why implicit concatenation is bad in this case? Is it breaking a particular scenario? Would love to understand more about the reason for this change. |
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.
Description of changes:
fix this issue avoid relying on implicit concatenation when building a list of strings; instead, ensure each list element is a complete string and separated with a comma. In this specific case, the
source="\n".join([...])list should contain one element for the#pragmaline and another element for thekraus(...) q[0]line, matching the surrounding pattern where each line of OpenQASM is a separate entry.Concretely, in
test/unit_tests/braket/circuits/test_circuit.pyreplace the two adjacent string literals:with two separate list elements by removing the implicit concatenation and making each line an explicit element separated by a comma:
"#pragma braket noise kraus([[0.9486833im, 0], [0, 0.9486833im]], [[0, 0.31622777], [0.31622777, 0]]) q[0]",or, if the intent is to have the pragma and the kraus call on separate lines:
Given the existing OpenQASM pragma syntax already combines the directive and its argument on one line earlier in the file, the minimal change that preserves current behavior while removing implicit concatenation is to combine them into a single explicit string element.
General
Tests
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.