Fix test assertion in raw_types_test.py.#7401
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7401 +/- ##
=======================================
Coverage 98.69% 98.69%
=======================================
Files 1112 1112
Lines 97965 97965
=======================================
Hits 96687 96687
Misses 1278 1278 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
pavoljuhas
left a comment
There was a problem hiding this comment.
I wonder if we should be testing the _decompose_ method directly or rather its effect on the public cirq.decompose API.
How about changing it like this:
diff --git a/cirq-core/cirq/ops/raw_types_test.py b/cirq-core/cirq/ops/raw_types_test.py
index c4fda0413..b819ade48 100644
--- a/cirq-core/cirq/ops/raw_types_test.py
+++ b/cirq-core/cirq/ops/raw_types_test.py
@@ -652,6 +652,5 @@ def test_tagged_operation_forwards_protocols() -> None:
np.testing.assert_equal(cirq.unitary(tagged_h), cirq.unitary(h))
assert cirq.has_unitary(tagged_h)
- assert cirq.decompose(tagged_h) == cirq.decompose(h)
- assert [*tagged_h._decompose_()] == cirq.decompose(h)
+ assert cirq.decompose(tagged_h) == cirq.decompose_once(h)
assert cirq.pauli_expansion(tagged_h) == cirq.pauli_expansion(h)
assert cirq.equal_up_to_global_phase(h, tagged_h)
Otherwise LGTM.
We can verify the call of `decompose_once` via public API.
|
@codrut3 - I have pushed a small tweak from my comment above - #7401 (review). Please let me know if it is OK with you. LGTM for myself. |
I'm not sure this is correct. My understanding is that cirq.decompose() attempts to recursively decompose using dfs, so it shouldn't be equivalent to a single step of decomposition. On the other hand, the So if you don't want to test |
|
@codrut3 - thanks for catching that - reverting back to your version. |
This fixes a small issue that I found while working on quantumlib#7291 TaggedOperation `_decompose_` calls `protocols.decompose_once` (see [here](https://github.com/quantumlib/Cirq/blob/e27d883d20d4acea97bd96d795170ae984b3dba9/cirq-core/cirq/ops/raw_types.py#L837)). So it must be compared against `cirq.decompose_once`. --------- Co-authored-by: Pavol Juhas <juhas@google.com>
This fixes a small issue that I found while working on quantumlib#7291 TaggedOperation `_decompose_` calls `protocols.decompose_once` (see [here](https://github.com/quantumlib/Cirq/blob/e27d883d20d4acea97bd96d795170ae984b3dba9/cirq-core/cirq/ops/raw_types.py#L837)). So it must be compared against `cirq.decompose_once`. --------- Co-authored-by: Pavol Juhas <juhas@google.com>
This fixes a small issue that I found while working on #7291
TaggedOperation
_decompose_callsprotocols.decompose_once(see here). So it must be compared againstcirq.decompose_once.