fix: remove custom MultiControlledX.__repr__ - #10190
andrijapau wants to merge 7 commits into
Conversation
MultiControlledX.__repr__
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10190 +/- ##
==========================================
- Coverage 99.41% 99.41% -0.01%
==========================================
Files 603 603
Lines 66975 66967 -8
==========================================
- Hits 66580 66572 -8
Misses 395 395 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| ) | ||
|
|
||
| def __repr__(self): | ||
| params = [f"wires={self.wires}"] |
There was a problem hiding this comment.
Only notable change - the rest is qp.math -> math.
| >>> mapped_circuit = circuit.map_to_standard_wires() | ||
| >>> mapped_circuit.circuit | ||
| [MultiControlledX(wires=[0, 1, 2, 3]), probs(wires=[3, 4, 5])] | ||
| [MultiControlledX(wires=[0, 1, 2, 3], control_values=[ True True True], work_wires=[6, 5], work_wire_type=borrowed), probs(wires=[3, 4, 5])] |
There was a problem hiding this comment.
Should we keep it so that trivial control_values don't get printed?
There was a problem hiding this comment.
For arbitrary controlled operators, we only print the control values if there are tracers, it is abstract, or there are zero-controls. For consistency, I would say that we should do the same for MCX
| >>> pprint(ops) | ||
| [StatePrep(array([0.707..., 0.707...]), wires=[1]), | ||
| MultiControlledX(wires=[0, 1, 2], control_values=[False, True]), | ||
| MultiControlledX(wires=[0, 1, 2], control_values=[False True], work_wires=[], work_wire_type=borrowed), |
There was a problem hiding this comment.
I think it also makes sense to override __repr__ so that we can print control_values.tolist() instead of the array, which should make the formatting a bit nicer
Co-authored-by: Mudit Pandey <18223836+mudit2812@users.noreply.github.com>
Context:
This PR improves MCX's repr to use the base
Operator.__repr__to improve debuggability.[sc-130135]