-
Notifications
You must be signed in to change notification settings - Fork 47
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 conditional parameter to gate counting #1662
Changes from 4 commits
ff4118b
2d674b6
34cf240
6f85315
127a9cc
ba9b76f
c5cca0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -472,15 +472,22 @@ void def_circuit(py::class_<Circuit, std::shared_ptr<Circuit>> &pyCircuit) { | |
"\n\n:return: the circuit depth") | ||
.def( | ||
"n_gates_of_type", | ||
[](const Circuit &circ, const OpType &_type) { | ||
return circ.count_gates(_type); | ||
[](const Circuit &circ, const OpType &_type, const bool conditional) { | ||
if (conditional) { | ||
return circ.count_gates(_type) + | ||
circ.count_gates_conditional(_type); | ||
} else { | ||
return circ.count_gates(_type); | ||
} | ||
}, | ||
"Returns the number of vertices in the dag of a given " | ||
"operation type.\n\n>>> c.CX(0,1)\n>>> c.H(0)\n>>> " | ||
"c.CX(0,1)\n>>> c.n_gates_of_type(OpType.CX)\n2\n\n:param " | ||
"type: The operation type to search for\n:return: the " | ||
"number of operations matching `type`", | ||
py::arg("type")) | ||
"type: The operation type to search for\n:param " | ||
"conditional: if set to true, conditional gates will " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in 127a9cc |
||
"be counted, too\n:return: the number of operations " | ||
"matching `type`", | ||
py::arg("type"), py::arg("conditional") = false) | ||
.def( | ||
"n_1qb_gates", | ||
[](const Circuit &circ) { return circ.count_n_qubit_gates(1); }, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1119,6 +1119,7 @@ class Circuit { | |
std::map<OpType, unsigned> op_counts() const; | ||
|
||
unsigned count_gates(const OpType &op_type) const; | ||
unsigned count_gates_conditional(const OpType &op_type) const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should just add an optional argument to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in 127a9cc |
||
VertexSet get_gates_of_type(const OpType &op_type) const; | ||
|
||
/** | ||
|
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.
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.
done in 127a9cc
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.
Added this for the return, too.