guan404ming commented on code in PR #626:
URL: https://github.com/apache/mahout/pull/626#discussion_r2524213504
##########
testing/test_single_qubit_gates.py:
##########
@@ -386,6 +417,67 @@ def test_u_gate_operations(
f"Expected ~0.5 probability for |1⟩ after
U({theta},{phi},{lambd}), "
f"got {prob_one}"
)
+ elif expected_behavior == "superposition":
+ # Should create a superposition (not all probability in one state)
+ prob_zero, prob_one = get_superposition_probabilities(results,
num_qubits=1)
+ # At least one state should have significant probability (> 0.1)
+ # and not all probability should be in one state (< 0.9)
+ assert (
+ prob_zero > 0.1 or prob_one > 0.1
+ ), f"Expected superposition after U({theta},{phi},{lambd}), got
prob_zero={prob_zero:.4f}, prob_one={prob_one:.4f}"
+ assert (
+ prob_zero < 0.9 and prob_one < 0.9
+ ), f"Expected superposition after U({theta},{phi},{lambd}), got
prob_zero={prob_zero:.4f}, prob_one={prob_one:.4f}"
+
+
+def test_u_gate_cross_backend_consistency():
+ """Test that U gate produces consistent results across all backends."""
+ # Test cases with non-zero phi to detect decomposition errors
+ test_cases = [
Review Comment:
Let's make them parameterized~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]