`Circuit::num_gates` not consistent with TKET `n_gates`
The following surprised me. Consider a circuit made of a single rotation:
c = Circuit(1).Rz(0.5, 0)
Obviously, in TK1 we have
c.n_gates # this is 1
However, in TK2, we get
let c_str = r#"{"bits": [], "commands": [{"args": [["q", [0]]], "op": {"params": ["0.5"], "type": "Rz"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]]], "phase": "0.0", "qubits": [["q", [0]]]}"#;
let ser: circuit_json::SerialCircuit = serde_json::from_str(c_str).unwrap();
let circ: Hugr = ser.decode().unwrap();
circ.num_gates() // this is 3
After reducing it to this example, it became clear to me that the overhead are the constant nodes introduced, but this is confusing.
At least num_gates() seems like the wrong name; should be num_nodes() or something.
I would also be fine with the current behaviour, but then we should
- make it explicit in the docs
- have another method that counts gates TK1-style; I need that for benchmarking (suggestion:
num_q_gates).
We should define what is a gate somewhere (clearly it's not the same as an Op).
I would suggest avoiding "gate" as an additional concept, and instead something like num_q_ops