-
Notifications
You must be signed in to change notification settings - Fork 118
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
change: Increase types module coverage to 100% and fix related bugs #595
change: Increase types module coverage to 100% and fix related bugs #595
Conversation
Codecov Report
@@ Coverage Diff @@
## feature/autoqasm #595 +/- ##
===================================================
Coverage ? 99.21%
===================================================
Files ? 146
Lines ? 8489
Branches ? 1836
===================================================
Hits ? 8422
Misses ? 49
Partials ? 18 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR does more than just raise coverage; can you include the source change details and change the PR/commit name accordingly?
@wrap_value.register | ||
def _(node: python_ast.Name, **kwargs: dict): | ||
return oqpy.classical_types.Identifier(node.id) | ||
|
||
|
||
@wrap_value.register | ||
def _(node: python_ast.BinOp, **kwargs: dict): | ||
return wrap_value(node.op, left=node.left, right=node.right) | ||
|
||
|
||
@wrap_value.register | ||
def _(node: python_ast.Add, **kwargs: dict): | ||
left = kwargs["left"] | ||
right = kwargs["right"] | ||
return oqpy.base.OQPyBinaryExpression( | ||
getattr(qasm_ast.BinaryOperator, "+"), | ||
wrap_value(left), | ||
wrap_value(right), | ||
) | ||
|
||
|
||
@wrap_value.register | ||
def _(node: python_ast.Sub, **kwargs: dict): | ||
left = kwargs["left"] | ||
right = kwargs["right"] | ||
return oqpy.base.OQPyBinaryExpression( | ||
getattr(qasm_ast.BinaryOperator, "-"), | ||
wrap_value(left), | ||
wrap_value(right), | ||
) | ||
|
||
|
||
@wrap_value.register | ||
def _(node: python_ast.Call, **kwargs: dict): | ||
if node.func.id == "range": | ||
arg_values = [wrap_value(arg) for arg in node.args] | ||
return range(*arg_values) | ||
|
||
|
||
@wrap_value.register | ||
def _(node: python_ast.Compare, **kwargs: dict): | ||
if len(node.ops) > 1: | ||
raise NotImplementedError(node) | ||
op = node.ops[0] | ||
op_map = { | ||
python_ast.Eq: "==", | ||
python_ast.NotEq: "!=", | ||
python_ast.Lt: "<", | ||
python_ast.LtE: "<=", | ||
python_ast.Gt: ">", | ||
python_ast.GtE: ">=", | ||
} | ||
return oqpy.base.OQPyBinaryExpression( | ||
getattr(qasm_ast.BinaryOperator, op_map[type(op)]), | ||
wrap_value(node.left), | ||
wrap_value(node.comparators[0]), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the removals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused code, and no known way to reach these code paths. I'd consider this unsupported.
I wonder why there's no more diff coverage information... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion, feel free to take or leave
Issue #, if available:
Description of changes:
Increase code coverage to 100% for types modules of AutoQASM
where various means: bit, bool, int, float, array, program.Program and some other random input to check implicit handling
Testing done:
New unit tests!
Merge Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.General
Tests
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.