feat: Register modifiers as Python functions#1557
Closed
nicolaassolini-qntm wants to merge 13 commits intomainfrom
Closed
feat: Register modifiers as Python functions#1557nicolaassolini-qntm wants to merge 13 commits intomainfrom
nicolaassolini-qntm wants to merge 13 commits intomainfrom
Conversation
Contributor
Contributor
|
| Branch | na/1290-modifiers-as-python-functions |
| Testbed | Linux |
Click to view all benchmark results
| Benchmark | hugr_bytes | Benchmark Result bytes x 1e3 (Result Δ%) | Upper Boundary bytes x 1e3 (Limit %) | hugr_nodes | Benchmark Result nodes (Result Δ%) | Upper Boundary nodes (Limit %) |
|---|---|---|---|---|---|---|
| tests/benchmarks/test_big_array.py::test_big_array_compile | 📈 view plot 🚷 view threshold | 141.73 x 1e3(0.00%)Baseline: 141.73 x 1e3 | 143.15 x 1e3 (99.01%) | 📈 view plot 🚷 view threshold | 6,620.00(0.00%)Baseline: 6,620.00 | 6,686.20 (99.01%) |
| tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile | 📈 view plot 🚷 view threshold | 17.52 x 1e3(0.00%)Baseline: 17.52 x 1e3 | 17.69 x 1e3 (99.01%) | 📈 view plot 🚷 view threshold | 581.00(0.00%)Baseline: 581.00 | 586.81 (99.01%) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1557 +/- ##
==========================================
- Coverage 93.39% 93.33% -0.06%
==========================================
Files 128 129 +1
Lines 11970 12006 +36
==========================================
+ Hits 11179 11206 +27
- Misses 791 800 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
I also wonder if a similar solution may be useful to catch other reserved keywords |
Contributor
Author
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.
See #1290 as reference
Quite a hacky solution:
I have defined a new decorator
guppy.modifierthat registers the class as aRawModifierDef.This definition is basically an empty definition (as we see in
guppylang/src/guppylang/std/modifier.pyand it is used to detect wrong modifier usage:guppylang/guppylang-internals/src/guppylang_internals/checker/expr_checker.py
Line 443 in ba283b0
I also added a check here:
guppylang/guppylang-internals/src/guppylang_internals/checker/modifier_checker.py
Lines 134 to 135 in ba283b0
I'm wondering about doing a complete refactor of the modifier, basically defining it as a special guppy function (this may solve other issues here, such as #1288
See
modifier_playground.ipynbfor an example.P.S. ignore my TODO comment, is still a draft