Repository: quantumlib/Cirq

Issue:
Document new simulators



Discussion:

Resolving patch:
diff --git a/cirq/ops/common_channels.py b/cirq/ops/common_channels.py
--- a/cirq/ops/common_channels.py
+++ b/cirq/ops/common_channels.py
@@ -514,11 +514,11 @@ def __init__(self, p) -> None:
 
         With:
 
-            M_0 = \sqrt{p} \begin{bmatrix}
+            M_0 = \sqrt{1 - p} \begin{bmatrix}
                                 1 & 0  \\
                                 0 & 1
                             \end{bmatrix}
-            M_1 = \sqrt{1-p} \begin{bmatrix}
+            M_1 = \sqrt{p} \begin{bmatrix}
                                 1 & 0 \\
                                 0 & -1
                             \end{bmatrix}
@@ -530,7 +530,7 @@ def __init__(self, p) -> None:
             ValueError: if p is not a valid probability.
         """
         self._p = value.validate_probability(p, 'p')
-        self._delegate = AsymmetricDepolarizingChannel(0., 0., 1. - p)
+        self._delegate = AsymmetricDepolarizingChannel(0., 0., p)
 
     def _mixture_(self) -> Sequence[Tuple[float, np.ndarray]]:
         mixture = self._delegate._mixture_()
@@ -639,13 +639,13 @@ def __init__(self, p) -> None:
 
         With:
 
-            M_0 = \sqrt{p} \begin{bmatrix}
+            M_0 = \sqrt{1 - p} \begin{bmatrix}
                                 1 & 0  \\
                                 0 & 1
                            \end{bmatrix}
-            M_1 = \sqrt{1-p} \begin{bmatrix}
+            M_1 = \sqrt{p} \begin{bmatrix}
                                 0 & 1 \\
-                                1 & -0
+                                1 & 0
                              \end{bmatrix}
 
         Args:
@@ -655,7 +655,7 @@ def __init__(self, p) -> None:
             ValueError: if p is not a valid probability.
         """
         self._p = value.validate_probability(p, 'p')
-        self._delegate = AsymmetricDepolarizingChannel(1. - p, 0., 0.)
+        self._delegate = AsymmetricDepolarizingChannel(p, 0., 0.)
 
     def _mixture_(self) -> Sequence[Tuple[float, np.ndarray]]:
         mixture = self._delegate._mixture_()


Test patch:
diff --git a/cirq/ops/common_channels_test.py b/cirq/ops/common_channels_test.py
--- a/cirq/ops/common_channels_test.py
+++ b/cirq/ops/common_channels_test.py
@@ -285,17 +285,14 @@ def test_phase_damping_channel_text_diagram():
 
 def test_phase_flip_channel():
     d = cirq.phase_flip(0.3)
-    np.testing.assert_almost_equal(cirq.channel(d),
-                                  (np.sqrt(0.3) * np.eye(2),
-                                   np.sqrt(1.-0.3) * Z))
+    np.testing.assert_almost_equal(
+        cirq.channel(d), (np.sqrt(1. - 0.3) * np.eye(2), np.sqrt(0.3) * Z))
     assert cirq.has_channel(d)
 
 
 def test_phase_flip_mixture():
     d = cirq.phase_flip(0.3)
-    assert_mixtures_equal(cirq.mixture(d),
-                          ((0.3, np.eye(2)),
-                           (0.7, Z)))
+    assert_mixtures_equal(cirq.mixture(d), ((0.7, np.eye(2)), (0.3, Z)))
     assert cirq.has_mixture_channel(d)
 
 
@@ -340,17 +337,14 @@ def test_phase_flip_channel_text_diagram():
 
 def test_bit_flip_channel():
     d = cirq.bit_flip(0.3)
-    np.testing.assert_almost_equal(cirq.channel(d),
-                                  (np.sqrt(0.3) * np.eye(2),
-                                   np.sqrt(1.0 - 0.3) * X))
+    np.testing.assert_almost_equal(
+        cirq.channel(d), (np.sqrt(1.0 - 0.3) * np.eye(2), np.sqrt(.3) * X))
     assert cirq.has_channel(d)
 
 
 def test_bit_flip_mixture():
     d = cirq.bit_flip(0.3)
-    assert_mixtures_equal(cirq.mixture(d),
-                          ((0.3, np.eye(2)),
-                           (0.7, X)))
+    assert_mixtures_equal(cirq.mixture(d), ((0.7, np.eye(2)), (0.3, X)))
     assert cirq.has_mixture_channel(d)