-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
filter_function for circuit.depth() and circuit.size() #6998
Conversation
|
||
Args: | ||
filter_function (callable): a function to filter out some instructions. | ||
Should take as input a tuple of (Instruction, list(Qubit), list(Clbit)). |
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 wondering if it makes more sense to flatten this one layer and use 3 positional args. It might be easier for people to create functions like:
def filter_fn(instruction, qargs, cargs):
instead of:
def filter_fn(inst_tuple):
instruction = inst_tuple[0]
qargs = inst_tuple[1]
cargs = inst_tuple[2]
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 intentionally did it this way because I think we really need something in Qiskit to represent the tuple (inst, qubit, clbits). I was actually going to do that as a followup, using a namedtuple or something. It comes up over and over again that you need the operation plus the operands. I think that is the basic unit of a circuit (i.e. one line of qasm).
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.
Tests indicate something that needs fixing.
0ab5692
to
9668618
Compare
9668618
to
56590dd
Compare
adding the ability to filter by instructions when inquiring circuit.depth() or circuit.size()
closes #6702