Skip to content

Added support to Angle, extern and Complex type#239

Merged
TheGupta2012 merged 13 commits intomainfrom
feature/types
Aug 11, 2025
Merged

Added support to Angle, extern and Complex type#239
TheGupta2012 merged 13 commits intomainfrom
feature/types

Conversation

@vinayswamik
Copy link
Copy Markdown
Collaborator

@vinayswamik vinayswamik commented Aug 3, 2025

Summary of changes

Add angle type support in QASM

  • Introduced angle_bit_string attribute in the Variable class to represent angle values.
  • Updated the loads function to accept compiler_angle_type_size for angle type width.
  • Enhanced Qasm3ExprEvaluator to validate angle variables in expressions, ensuring consistent size.
  • Implemented angle type validation in PulseValidator and updated related tests for angle declarations and assignments.
  • Added tests to check for angle type errors and compiler angle type size handling.

Add support for complex type operations in QASM

  • Introduced a FUNCTION_MAP for complex functions such as abs, real, imag, sqrt, sin, cos, and tan.
  • Updated Qasm3ExprEvaluator to handle complex expressions and added checks for complex types.
  • Enhanced PulseValidator to create binary expressions from complex numbers.
  • Added tests for complex type variables and operations in QASM.

Add extern function support in QASM

  • Introduced handling for extern function declarations and calls, allowing for external function integration within QASM programs.
  • Updated the QasmModule to store extern function definitions.
  • Enhanced the Qasm3ExprEvaluator and QasmVisitor to process extern functions, including validation and argument type checks.
  • Added tests to validate extern function calls and error handling for mismatched parameters and return types.

Closes #34
Closes #33
Closes #204

@vinayswamik vinayswamik changed the title Added support to 'Angle' type Added support to Angle type Aug 3, 2025
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Aug 3, 2025

Codecov Report

❌ Patch coverage is 99.61538% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pyqasm/visitor.py 98.90% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@vinayswamik vinayswamik changed the title Added support to Angle type Added support to Angle and Complex type Aug 3, 2025
Copy link
Copy Markdown
Member

@TheGupta2012 TheGupta2012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vinayswamik , code looks good! Some minor comments but should be good to go. Are you adding extern with this PR as well?

@vinayswamik
Copy link
Copy Markdown
Collaborator Author

Hi @vinayswamik , code looks good! Some minor comments but should be good to go. Are you adding extern with this PR as well?

Yeah, i will add extern to the same PR.

- Changed `angle_vars_in_expr` to a single variable `angle_var_in_expr` for improved clarity and functionality.
- Introduced new trigonometric functions (`arccos`, `arcsin`, `arctan`) to the FUNCTION_MAP.
- Adjusted tests to validate new angle expressions and ensure correct bit string conversions.
@vinayswamik vinayswamik changed the title Added support to Angle and Complex type Added support to Angle, extern and Complex type Aug 5, 2025
- Updated `Qasm3ExprEvaluator` to include support for `BitstringLiteral` in expression evaluations.
- Improved `Qasm3SubroutineProcessor` to validate argument types, including checks for `BitType` and `AngleType`.
- Added a new method in `QasmVisitor` to validate the width of bitstring literals.
- Adjusted `PulseValidator` to handle string representations of bitstrings.
- Updated tests to reflect changes in bitstring handling and validation logic.
Copy link
Copy Markdown
Member

@TheGupta2012 TheGupta2012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vinayswamik , can you please address these changes? Should be good to merge post that!

@TheGupta2012 TheGupta2012 self-requested a review August 11, 2025 09:42
Copy link
Copy Markdown
Member

@TheGupta2012 TheGupta2012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TheGupta2012 TheGupta2012 merged commit 5d8dc97 into main Aug 11, 2025
21 checks passed
@vinayswamik vinayswamik deleted the feature/types branch August 11, 2025 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add support for extern [FEATURE] Add support for angle types [FEATURE] Add support for complex types

3 participants