-
Notifications
You must be signed in to change notification settings - Fork 16
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
Enable v3 MVP to be used from Python #169
Merged
Merged
Conversation
This file contains 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
Implemented v3x default_analyzer.
Changed import line into three lines, as suggested by clang-tidy.
…ted by clang-tidy.
Also tried to make the file more readable, while not changing its rendered output.
Changed qasminterface to qasm_interface.
Added test_v3x_analyzer.py.
When I run pytest, it is not finding test/v3x/python/test_v3x_analyzer.py.
…hon/test_v3x_analyzer.py'. TODO: have 'TestV3xAnalyzer::parse_string' recognized when running pytest, and implement it.
We are trying to avoid including 'antlr4-runtime.h' from some header files that are being included at the same time that a conflicting Python header. The conflicting Python header contains some defines, e.g., STRING, that 'antlr4-runtime.h' uses as enumeration values. The build process substitutes those defines in the 'antlr4-runtime.h' code, resulting in many build errors.
We are trying to avoid including 'antlr4-runtime.h' from some header files that are being included at the same time that a conflicting Python header. The conflicting Python header contains some defines, e.g., STRING, that 'antlr4-runtime.h' uses as enumeration values. The build process substitutes those defines in the 'antlr4-runtime.h' code, resulting in many build errors.
pablolh
reviewed
Nov 27, 2023
We still have the same problem though as we have for the json_parser branch: AttributeError: module 'libQasm' has no attribute 'V3xAnalyzer'.
# Conflicts: # src/v3x/cqasm-py.cpp
With code: return ast.Program.deserialize(retval[0].encode("utf-8", errors="surrogateescape")) We are now converting retval[0] to a string before encoding.
We also need to convert every error from a "libQasm string" to a "Python string" before returning.
The analyzer functions always return a vector of strings. And, in this vector, the first string is reserved for the serialized AST. The next strings are filled with error messages, if any.
To exercise the parse_string and analyze_string APIs. Both when an AST or a list of errors is returned.
pablolh
reviewed
Dec 4, 2023
pablolh
previously approved these changes
Dec 5, 2023
pablolh
approved these changes
Dec 5, 2023
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.
Renamed
V1xAnalyzer::a
member toV1xAnalyzer::analyzer
. The same for v3.Renamed
python/module/cqasm/v1x/__init__.py
Analyzer
class toV1xAnalzyer
. The same for v3.python/libQasm.i
now also includesv3x/cqasm-py.hpp
.test/v3x
now hascpp
and apython
subdirectories.test/v1x
also has acpp
subdirectory.Added
test/v3x/python/test_v3x_analyzer.py
.Removed
pyproject.toml
, and addedpytest.ini
.Implemented
src/v3x/cqasm.cpp
default_analyzer
.cqasm-analyzer
now hasanalyze_file
andanalyze_string
methods (previouslyanalyze
andanalyze_string
).