-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add convenience method Circuit.add_clexpr_from_logicexp()
#1681
Conversation
9db39a8
to
09e2fc4
Compare
Circuit.add_clexpr_from_logicexp()
":param exp: logical expression\n" | ||
":param output_bits: list of bits in output\n" | ||
":return: the updated circuit", | ||
py::arg("exp"), py::arg("output_bits")) |
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.
py::arg("exp"), py::arg("output_bits")) | |
py::arg("exp"), py::arg("output")) |
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.
And allow sequence[bits] and register?
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 I prefer output_bits
as it is more explicit.
Any sequence of bits should work here.
In principle the output bits do not need to form a register (though that would be the case usually), so I'm not sure it's worth adding an overload.
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 the question is, would this work, and if not do we want it to?
c = Circuit()
x_reg = c.add_c_register('x', 3)
y_reg = c.add_c_register('y', 3)
z_reg = c.add_c_register('z', 3)
c.add_clexpr_from_logicexp(x_reg | y_reg, z_reg)
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.
Yes that does work; the register is coerced to a list.
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.
(ISTR mypy doesn't like it though.)
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.
Could we add an additional stubs for that, to make mypy happy?
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'm not sure how to do that?
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 we would need a second c++ function in the binders for that, but not sure if there might be a easier way?
If you think that is not worth the effort happy to approve this as it is.
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.
Yeah, I don't think it's worth the effort (and maintenance) of an extra binder just to fix a mypy problem.
No description provided.