.qcall() method for automatic deduction of parameters, helper BloqBuilder methods#1862
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the qcall pattern to Qualtran, providing a more concise and functional syntax for composing bloqs using QVar objects. The changes include comprehensive documentation for the pattern, operator overloading for QVar (supporting ~, +, and +=), and the implementation of qcall classmethods across a wide range of arithmetic and basic gate bloqs. Additionally, BloqBuilder was updated with helper methods to facilitate these calls. The review feedback identifies a recurring issue across several qcall implementations where the code fails to account for multi-qubit registers represented as numpy arrays, which would lead to AttributeError when attempting to access .bb or .dtype properties directly.
The annotations are correct. If the code fails, it's because you're not supposed to put a numpy array there |
qcallclass method onbasic_gates/and somearithmetic/bloqsBloqBuilder.CNOTand other shorthandsqcallmethodpart of #1741