-
Notifications
You must be signed in to change notification settings - Fork 28
feat: Define modifiers as Python functions #1571
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
Open
nicolaassolini-qntm
wants to merge
7
commits into
main
Choose a base branch
from
na/1290-define-modifiers-as-python-functions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9c9ec94
added dummy object in std.lang
nicolaassolini-qntm a196109
updated test files
nicolaassolini-qntm 718d952
Merge remote-tracking branch 'origin/main' into na/1290-define-modifi…
nicolaassolini-qntm 8b25315
added comptime error to modifier
nicolaassolini-qntm ca905ee
added tests
nicolaassolini-qntm 032bce7
fix error rendering
nicolaassolini-qntm f30493d
ruff
nicolaassolini-qntm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,15 @@ | ||
| Error: Copy violation (at $FILE:12:20) | ||
| Error: Copy violation (at $FILE:13:20) | ||
| | | ||
| 10 | def test() -> None: | ||
| 11 | q = qubit() | ||
| 12 | with control(q, q): | ||
| 11 | def test() -> None: | ||
| 12 | q = qubit() | ||
| 13 | with control(q, q): | ||
| | ^ Variable `q` with non-copyable type `qubit` cannot be | ||
| | borrowed ... | ||
|
|
||
| Note: | ||
| | | ||
| 11 | q = qubit() | ||
| 12 | with control(q, q): | ||
| 12 | q = qubit() | ||
| 13 | with control(q, q): | ||
| | - Variable `q` already borrowed here | ||
|
|
||
| Guppy compilation failed due to 1 previous error |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,15 @@ | ||
| Error: Copy violation (at $FILE:17:12) | ||
| Error: Copy violation (at $FILE:18:12) | ||
| | | ||
| 15 | q = qubit() | ||
| 16 | with control(q): | ||
| 17 | use(q) | ||
| 16 | q = qubit() | ||
| 17 | with control(q): | ||
| 18 | use(q) | ||
| | ^ Variable `q` with non-copyable type `qubit` cannot be | ||
| | borrowed ... | ||
|
|
||
| Note: | ||
| | | ||
| 15 | q = qubit() | ||
| 16 | with control(q): | ||
| 16 | q = qubit() | ||
| 17 | with control(q): | ||
| | - Variable `q` already borrowed here | ||
|
|
||
| Guppy compilation failed due to 1 previous error |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| Error: Type mismatch (at $FILE:7:20) | ||
| Error: Type mismatch (at $FILE:9:20) | ||
| | | ||
| 5 | def test() -> None: | ||
| 6 | x = qubit() | ||
| 7 | with control(x, True): | ||
| 7 | def test() -> None: | ||
| 8 | x = qubit() | ||
| 9 | with control(x, True): | ||
| | ^^^^ Expected expression of type `qubit`, got `bool` | ||
|
|
||
| Guppy compilation failed due to 1 previous error |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| Error: Not enough arguments (at $FILE:8:16) | ||
| Error: Not enough arguments (at $FILE:9:16) | ||
| | | ||
| 6 | @guppy | ||
| 7 | def test() -> None: | ||
| 8 | with control(): | ||
| 7 | @guppy | ||
| 8 | def test() -> None: | ||
| 9 | with control(): | ||
| | ^^ Missing argument (expected 1, got 0) | ||
|
|
||
| Guppy compilation failed due to 1 previous error |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| Error: Too many arguments (at $FILE:6:16) | ||
| Error: Too many arguments (at $FILE:7:16) | ||
| | | ||
| 4 | @guppy | ||
| 5 | def test() -> None: | ||
| 6 | with dagger(1): | ||
| 5 | @guppy | ||
| 6 | def test() -> None: | ||
| 7 | with dagger(1): | ||
| | ^ Unexpected argument (expected 0, got 1) | ||
|
|
||
| Guppy compilation failed due to 1 previous error |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| from guppylang.decorator import guppy | ||
| from guppylang.std.builtins import dagger | ||
|
|
||
|
|
||
| @guppy | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| Error: Invalid expression in dagger (at $FILE:7:8) | ||
| Error: Invalid expression in dagger (at $FILE:8:8) | ||
| | | ||
| 5 | def test() -> None: | ||
| 6 | with dagger: | ||
| 7 | a = 3 | ||
| 6 | def test() -> None: | ||
| 7 | with dagger: | ||
| 8 | a = 3 | ||
| | ^^^^^ Assignment found in a dagger context | ||
|
|
||
| Note: | ||
| | | ||
| 5 | def test() -> None: | ||
| 6 | with dagger: | ||
| 6 | def test() -> None: | ||
| 7 | with dagger: | ||
| | ------ dagger modifier is used here | ||
|
|
||
| Guppy compilation failed due to 1 previous error |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| from guppylang.decorator import guppy | ||
| from guppylang.std.builtins import dagger | ||
|
|
||
|
|
||
| @guppy | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| Error: Invalid expression in dagger (at $FILE:7:8) | ||
| Error: Invalid expression in dagger (at $FILE:8:8) | ||
| | | ||
| 5 | def test() -> None: | ||
| 6 | with dagger: | ||
| 7 | for _ in range(46): | ||
| 6 | def test() -> None: | ||
| 7 | with dagger: | ||
| 8 | for _ in range(46): | ||
| | ^^^^^^^^^^^^^^^^^^^ | ||
| 8 | pass | ||
| 9 | pass | ||
| | ^^^^^^^^^^^^^^^^ Loop found in a dagger context | ||
|
|
||
| Note: | ||
| | | ||
| 5 | def test() -> None: | ||
| 6 | with dagger: | ||
| 6 | def test() -> None: | ||
| 7 | with dagger: | ||
| | ------ dagger modifier is used here | ||
|
|
||
| Guppy compilation failed due to 1 previous error |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| from guppylang.decorator import guppy | ||
| from guppylang.std.builtins import dagger | ||
|
|
||
|
|
||
| @guppy | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| Error: Unitary constraint violation (at $FILE:15:12) | ||
| Error: Unitary constraint violation (at $FILE:16:12) | ||
| | | ||
| 13 | with dagger: | ||
| 14 | with power(2): | ||
| 15 | foo(q) | ||
| 14 | with dagger: | ||
| 15 | with power(2): | ||
| 16 | foo(q) | ||
| | ^^^^^^ This function cannot be called in a dagger context | ||
|
|
||
| Guppy compilation failed due to 1 previous error |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| Error: Unitary constraint violation (at $FILE:15:12) | ||
| Error: Unitary constraint violation (at $FILE:16:12) | ||
| | | ||
| 13 | with control(ctrl), dagger: | ||
| 14 | with power(2): | ||
| 15 | foo(q) | ||
| 14 | with control(ctrl), dagger: | ||
| 15 | with power(2): | ||
| 16 | foo(q) | ||
| | ^^^^^^ This function cannot be called in a unitary context | ||
|
|
||
| Guppy compilation failed due to 1 previous error |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| Error: Unitary constraint violation (at $FILE:15:12) | ||
| Error: Unitary constraint violation (at $FILE:16:12) | ||
| | | ||
| 13 | with control(ctrl): | ||
| 14 | with dagger: | ||
| 15 | foo(q) | ||
| 14 | with control(ctrl): | ||
| 15 | with dagger: | ||
| 16 | foo(q) | ||
| | ^^^^^^ This function cannot be called in a dagger context | ||
|
|
||
| Guppy compilation failed due to 1 previous error |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| Error: Unitary constraint violation (at $FILE:15:12) | ||
| Error: Unitary constraint violation (at $FILE:16:12) | ||
| | | ||
| 13 | with dagger: | ||
| 14 | with power(2): | ||
| 15 | foo(q) | ||
| 14 | with dagger: | ||
| 15 | with power(2): | ||
| 16 | foo(q) | ||
| | ^^^^^^ This function cannot be called in a power context | ||
|
|
||
| Guppy compilation failed due to 1 previous error |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.