Repository: PennyLaneAI/pennylane
Pull request #1255 (2021-04-24 00:17:08)

Fix the order of arguments to the `GaussianState` operation
**Context:**
PennyLane considers the arguments to the `GaussianState` operation in a different order than Strawberry Fields.

**Description of the Change:**
Changes the documented order of the arguments to the `GaussianState` operation.

**Benefits:**
The documentation corresponds to the order in which parameters are passed in the PennyLane-SF plugin. The `default.gaussian` device is also adjusted accordingly.

**Possible Drawbacks:**
Out of scope for this PR, internally the `default.gaussian` device still continues to use a different covariance matrix and vector of means ordering than Strawberry Fields.

Opened an issue to tackle this: https://github.com/PennyLaneAI/pennylane/issues/1257

**Related GitHub Issues:**
https://github.com/PennyLaneAI/pennylane-sf/issues/67

github-actions[bot]: Hello. You may have forgotten to update the changelog!
Please edit [.github/CHANGELOG.md](/PennyLaneAI/pennylane/blob/master/.github/CHANGELOG.md) with:
* A one-to-two sentence description of the change. You may include a small working example for new features.
* A link back to this PR.
* Your name (or GitHub username) in the contributors section.
codecov[bot]: # [Codecov](https://codecov.io/gh/PennyLaneAI/pennylane/pull/1255?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) Report
> Merging [#1255](https://codecov.io/gh/PennyLaneAI/pennylane/pull/1255?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) (814b0b4) into [master](https://codecov.io/gh/PennyLaneAI/pennylane/commit/b81a579e47db988db251006ad25516a5c7d2a875?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) (b81a579) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/PennyLaneAI/pennylane/pull/1255/graphs/tree.svg?width=650&height=150&src=pr&token=9S3YzlUgGk&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI)](https://codecov.io/gh/PennyLaneAI/pennylane/pull/1255?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI)

```diff
@@           Coverage Diff           @@
##           master    #1255   +/-   ##
=======================================
  Coverage   98.14%   98.14%           
=======================================
  Files         146      146           
  Lines       11035    11035           
=======================================
  Hits        10830    10830           
  Misses        205      205           
```


| [Impacted Files](https://codecov.io/gh/PennyLaneAI/pennylane/pull/1255?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) | Coverage Δ | |
|---|---|---|
| [pennylane/ops/cv.py](https://codecov.io/gh/PennyLaneAI/pennylane/pull/1255/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI#diff-cGVubnlsYW5lL29wcy9jdi5weQ==) | `100.00% <ø> (ø)` | |
| [pennylane/devices/default\_gaussian.py](https://codecov.io/gh/PennyLaneAI/pennylane/pull/1255/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI#diff-cGVubnlsYW5lL2RldmljZXMvZGVmYXVsdF9nYXVzc2lhbi5weQ==) | `99.29% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/PennyLaneAI/pennylane/pull/1255?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/PennyLaneAI/pennylane/pull/1255?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI). Last update [b81a579...814b0b4](https://codecov.io/gh/PennyLaneAI/pennylane/pull/1255?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI).

glassnotes: > Thanks for working on this @antalszava! Would it perhaps be nice to add an integration test using the fock device as well here (testing the exact case as the one in the issue)? Couldn't really see anywhere where this was tested, i.e. that would have caught the issue in the first place.

@antalszava same comment about testing the `fock` device; when I tested it with the `default.gaussian` device things had run without issue. Unless, are the device-specific tests something that live in PennyLane-SF instead?
antalszava: @thisac @glassnotes thanks for the comments!

Yes, all testing is done in PennyLane-SF. If we were to add a test case here, we'd need PennyLane-SF to be a dependency of PennyLane. I can add a test there.

PennyLane core has the difference in storing & using the covariance matrices and vector of means from Strawberry Fields, that should be the reason for why it worked well with `default.gaussian`.
antalszava: The following test case in PennyLane-SF should cover our use case:
https://github.com/PennyLaneAI/pennylane-sf/blob/831131dbbe3b2e646a147522ea7f422137d03f71/tests/test_fock.py#L193

It has the correct order for gate parameters.

Patch:
diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md
index 7fe10c6a5..f5d2031b2 100644
--- a/.github/CHANGELOG.md
+++ b/.github/CHANGELOG.md
@@ -50,9 +50,13 @@
 
 <h3>Documentation</h3>
 
+* Updated the order of the parameters to the `GaussianState` operation to match
+  the way that the PennyLane-SF plugin uses them.
+  [(#1255)](https://github.com/PennyLaneAI/pennylane/pull/1255)
+
 <h3>Contributors</h3>
 
-This release contains contributions from:
+This release contains contributions from (in alphabetical order):
 
 Thomas Bromley, Diego Guala, Anthony Hayes, Antal Száva
 
diff --git a/pennylane/devices/default_gaussian.py b/pennylane/devices/default_gaussian.py
index ea4d47462..61bc88f6a 100644
--- a/pennylane/devices/default_gaussian.py
+++ b/pennylane/devices/default_gaussian.py
@@ -432,7 +432,7 @@ def thermal_state(nbar, hbar=2.0):
     return state
 
 
-def gaussian_state(mu, cov, hbar=2.0):
+def gaussian_state(cov, mu, hbar=2.0):
     r"""Returns a Gaussian state.
 
     This is simply a bare wrapper function,
@@ -444,17 +444,19 @@ def gaussian_state(mu, cov, hbar=2.0):
     ordering.
 
     Args:
-        mu (array): vector means. Must be length-:math:`2N`,
-            where N is the number of modes
         cov (array): covariance matrix. Must be dimension :math:`2N\times 2N`,
             where N is the number of modes
+        mu (array): vector means. Must be length-:math:`2N`,
+            where N is the number of modes
         hbar (float): (default 2) the value of :math:`\hbar` in the commutation
             relation :math:`[\x,\p]=i\hbar`
 
     Returns:
-        tuple: the mean and covariance matrix of the Gaussian state
+        tuple: the mean and the covariance matrix of the Gaussian state
     """
     # pylint: disable=unused-argument
+
+    # Note: the internal order of mu and cov is different to the one used in Strawberry Fields
     return mu, cov
 
 
diff --git a/pennylane/ops/cv.py b/pennylane/ops/cv.py
index 0539a0213..18d060791 100644
--- a/pennylane/ops/cv.py
+++ b/pennylane/ops/cv.py
@@ -710,7 +710,7 @@ class ThermalState(CVOperation):
 
 
 class GaussianState(CVOperation):
-    r"""pennylane.GaussianState(r, V, wires)
+    r"""pennylane.GaussianState(V, r, wires)
     Prepare subsystems in a given Gaussian state.
 
     **Details:**
@@ -720,9 +720,9 @@ class GaussianState(CVOperation):
     * Gradient recipe: None
 
     Args:
+        V (array): the :math:`2N\times 2N` (real and positive definite) covariance matrix
         r (array): a length :math:`2N` vector of means, of the
             form :math:`(\x_0,\dots,\x_{N-1},\p_0,\dots,\p_{N-1})`
-        V (array): the :math:`2N\times 2N` (real and positive definite) covariance matrix
     """
     num_wires = AnyWires
     num_params = 2


Test patch:
diff --git a/pennylane/devices/tests/conftest.py b/pennylane/devices/tests/conftest.py
index 686d76b46..a748006be 100755
--- a/pennylane/devices/tests/conftest.py
+++ b/pennylane/devices/tests/conftest.py
@@ -67,7 +67,7 @@ def skip_if():
     """Fixture to skip tests."""
 
     def _skip_if(dev, capabilities):
-        """ Skip test if device has any of the given capabilities. """
+        """Skip test if device has any of the given capabilities."""
 
         dev_capabilities = dev.capabilities()
         for capability, value in capabilities.items():
diff --git a/pennylane/devices/tests/test_properties.py b/pennylane/devices/tests/test_properties.py
index bebce8bd0..c833da422 100755
--- a/pennylane/devices/tests/test_properties.py
+++ b/pennylane/devices/tests/test_properties.py
@@ -39,7 +39,7 @@ except ImportError:
 
 
 def qfunc_no_input():
-    """Model agnostic quantum function """
+    """Model agnostic quantum function"""
     return qml.expval(qml.Identity(wires=0))
 
 
diff --git a/tests/circuit_drawer/test_circuit_drawer.py b/tests/circuit_drawer/test_circuit_drawer.py
index b336ca36d..1246862fe 100644
--- a/tests/circuit_drawer/test_circuit_drawer.py
+++ b/tests/circuit_drawer/test_circuit_drawer.py
@@ -429,7 +429,7 @@ def wide_cv_qnode():
 
     def qfunc():
         qml.GaussianState(
-            np.array([(2 * i + 2) // 2 for i in range(16)]), 2 * np.eye(16), wires=list(range(8))
+            2 * np.eye(16), np.array([(2 * i + 2) // 2 for i in range(16)]), wires=list(range(8))
         )
         [qml.Beamsplitter(0.4, 0, wires=[2 * i, 2 * i + 1]) for i in range(4)]
         [qml.Beamsplitter(0.25475, 0.2312344, wires=[i, i + 4]) for i in range(4)]
@@ -458,8 +458,6 @@ def drawn_wide_cv_qnode():
         + " 6: ──├Gaussian(M0,M1)──╭BS(0.4, 0)──│──────────────────╰BS(0.255, 0.231)──────────────────────────────────────────╰│┤ ⟨|1,1╳1,1|⟩ \n"
         + " 7: ──╰Gaussian(M0,M1)──╰BS(0.4, 0)──╰BS(0.255, 0.231)──────────────────────────────────────────────────────────────╰┤ ⟨|1,1╳1,1|⟩ \n"
         + "M0 =\n"
-        + "[ 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16]\n"
-        + "M1 =\n"
         + "[[2. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n"
         + " [0. 2. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n"
         + " [0. 0. 2. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n"
@@ -476,6 +474,8 @@ def drawn_wide_cv_qnode():
         + " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 2. 0. 0.]\n"
         + " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 2. 0.]\n"
         + " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 2.]]\n"
+        + "M1 =\n"
+        + "[ 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16]\n"
     )
 
 
@@ -485,7 +485,7 @@ def parameterized_cv_qnode():
 
     def qfunc(a, b, c, d, e, f):
         qml.ThermalState(3, wires=[1])
-        qml.GaussianState(np.array([1, 1, 1, 2, 2, 3, 3, 3]), 2 * np.eye(8), wires=[0, 1, 2, 3])
+        qml.GaussianState(2 * np.eye(8), np.array([1, 1, 1, 2, 2, 3, 3, 3]), wires=[0, 1, 2, 3])
         qml.Rotation(a, wires=0)
         qml.Rotation(b, wires=1)
         qml.Beamsplitter(d, 1, wires=[0, 1])
@@ -545,8 +545,6 @@ def drawn_parameterized_cv_qnode_with_values():
         + " 2: ──────────────├Gaussian(M0,M1)───────────────────────────╰BS(0.5, 1)──S(2.3, 0)──╰BS(2.76, 1)──╭BS(0.5, 1)──│─────────╰C───────│────────────╭┤ ⟨|1,5╳1,5|⟩       \n"
         + " 3: ──────────────╰Gaussian(M0,M1)──D(0.6, 0)──────────────────────────────────────────────────────╰BS(0.5, 1)──╰S(2, 2)───────────╰X(2)────────╰┤ ⟨|1,5╳1,5|⟩       \n"
         + "M0 =\n"
-        + "[1 1 1 2 2 3 3 3]\n"
-        + "M1 =\n"
         + "[[2. 0. 0. 0. 0. 0. 0. 0.]\n"
         + " [0. 2. 0. 0. 0. 0. 0. 0.]\n"
         + " [0. 0. 2. 0. 0. 0. 0. 0.]\n"
@@ -555,6 +553,8 @@ def drawn_parameterized_cv_qnode_with_values():
         + " [0. 0. 0. 0. 0. 2. 0. 0.]\n"
         + " [0. 0. 0. 0. 0. 0. 2. 0.]\n"
         + " [0. 0. 0. 0. 0. 0. 0. 2.]]\n"
+        + "M1 =\n"
+        + "[1 1 1 2 2 3 3 3]\n"
     )
 
 
diff --git a/tests/circuit_drawer/test_representation_resolver.py b/tests/circuit_drawer/test_representation_resolver.py
index 0a65e9fe9..c5e218685 100644
--- a/tests/circuit_drawer/test_representation_resolver.py
+++ b/tests/circuit_drawer/test_representation_resolver.py
@@ -113,7 +113,7 @@ class TestRepresentationResolver:
             (qml.ControlledPhase(3.14, wires=[0, 1]), 0, "C"),
             (qml.ThermalState(3, wires=[1]), 1, "Thermal(3)"),
             (
-                qml.GaussianState(np.array([1, 2]), np.array([[2, 0], [0, 2]]), wires=[1]),
+                qml.GaussianState(np.array([[2, 0], [0, 2]]), np.array([1, 2]), wires=[1]),
                 1,
                 "Gaussian(M0,M1)",
             ),
@@ -252,7 +252,7 @@ class TestRepresentationResolver:
             (qml.ControlledPhase(3.14, wires=[0, 1]), 0, "C"),
             (qml.ThermalState(3, wires=[1]), 1, "Thermal(3)"),
             (
-                qml.GaussianState(np.array([1, 2]), np.array([[2, 0], [0, 2]]), wires=[1]),
+                qml.GaussianState(np.array([[2, 0], [0, 2]]), np.array([1, 2]), wires=[1]),
                 1,
                 "Gaussian(M0,M1)",
             ),
diff --git a/tests/devices/test_default_gaussian.py b/tests/devices/test_default_gaussian.py
index 72bb11a65..7e61b8ad7 100644
--- a/tests/devices/test_default_gaussian.py
+++ b/tests/devices/test_default_gaussian.py
@@ -411,9 +411,11 @@ class TestDefaultGaussianDevice:
             if op.par_domain == "A":
                 # the parameter is an array
                 if gate_name == "GaussianState":
-                    p = [np.array([0.432, 0.123, 0.342, 0.123]), np.diag([0.5234] * 4)]
+                    cov = np.diag([0.5234] * 4)
+                    mu = np.array([0.432, 0.123, 0.342, 0.123])
+                    p = [cov, mu]
                     w = list(range(2))
-                    expected_out = p
+                    expected_out = [mu, cov]
                 elif gate_name == "Interferometer":
                     w = list(range(2))
                     p = [U]
@@ -782,7 +784,7 @@ class TestDefaultGaussianIntegration:
         def reference(*x):
             """reference circuit"""
             if g == "GaussianState":
-                return x[0][0]
+                return x[1][0]
 
             if g == "Displacement":
                 alpha = x[0] * np.exp(1j * x[1])
@@ -801,7 +803,7 @@ class TestDefaultGaussianIntegration:
             return (S @ np.array([a.real, a.imag, 0, 0]) * np.sqrt(2 * hbar))[0]
 
         if g == "GaussianState":
-            p = [np.array([0.432, 0.123, 0.342, 0.123]), np.diag([0.5234] * 4)]
+            p = [np.diag([0.5234] * 4), np.array([0.432, 0.123, 0.342, 0.123])]
         elif g == "Interferometer":
             p = [U]
         else:
diff --git a/tests/devices/test_default_mixed.py b/tests/devices/test_default_mixed.py
index b0ea47d7a..a0de1eeb2 100644
--- a/tests/devices/test_default_mixed.py
+++ b/tests/devices/test_default_mixed.py
@@ -162,7 +162,7 @@ class TestReset:
 
 @pytest.mark.parametrize("nr_wires", [1, 2, 3])
 class TestAnalyticProb:
-    """Unit tests for the method `analytic_probability()` """
+    """Unit tests for the method `analytic_probability()`"""
 
     def test_prob_init_state(self, nr_wires, tol):
         """Tests that we obtain the correct probabilities for the state |0...0><0...0|"""
diff --git a/tests/devices/test_default_qubit.py b/tests/devices/test_default_qubit.py
index 2bf4226bc..2f83dd7df 100644
--- a/tests/devices/test_default_qubit.py
+++ b/tests/devices/test_default_qubit.py
@@ -1846,7 +1846,7 @@ class TestWiresIntegration:
         assert np.allclose(circuit1(), circuit2(), tol)
 
     def test_wires_not_found_exception(self):
-        """Tests that an exception is raised when wires not present on the device are adressed. """
+        """Tests that an exception is raised when wires not present on the device are adressed."""
         dev = qml.device("default.qubit", wires=["a", "b"])
 
         with qml.tape.QuantumTape() as tape:
diff --git a/tests/devices/test_default_qubit_jax.py b/tests/devices/test_default_qubit_jax.py
index 5c97139f9..a214d8901 100644
--- a/tests/devices/test_default_qubit_jax.py
+++ b/tests/devices/test_default_qubit_jax.py
@@ -188,7 +188,7 @@ class TestQNodeIntegration:
         assert len(res) == 1000
 
     def test_gates_dont_crash(self):
-        """Test for gates that weren't covered by other tests. """
+        """Test for gates that weren't covered by other tests."""
         dev = qml.device("default.qubit.jax", wires=2, shots=1000)
 
         @qml.qnode(dev, interface="jax", diff_method="backprop")
diff --git a/tests/tape/test_qubit_param_shift.py b/tests/tape/test_qubit_param_shift.py
index 2c67702f5..174d54710 100644
--- a/tests/tape/test_qubit_param_shift.py
+++ b/tests/tape/test_qubit_param_shift.py
@@ -585,7 +585,7 @@ class TestHessian:
         assert np.allclose(autograd_val, manualgrad_val, atol=tol, rtol=0)
 
     def test_vector_output(self, tol):
-        """Tests that a vector valued output tape has a hessian with the proper result. """
+        """Tests that a vector valued output tape has a hessian with the proper result."""
 
         dev = qml.device("default.qubit", wires=1)
 
diff --git a/tests/templates/test_subroutines/test_permute.py b/tests/templates/test_subroutines/test_permute.py
index f0b2408cd..a33d5c063 100644
--- a/tests/templates/test_subroutines/test_permute.py
+++ b/tests/templates/test_subroutines/test_permute.py
@@ -23,7 +23,7 @@ class TestDecomposition:
     """Tests that the template defines the correct decomposition."""
 
     def test_identity_permutation_qnode(self):
-        """ Test that identity permutations have no effect on QNodes. """
+        """Test that identity permutations have no effect on QNodes."""
 
         dev = qml.device("default.qubit", wires=4)
 
@@ -40,7 +40,7 @@ class TestDecomposition:
         assert len(tape.operations) == 0
 
     def test_identity_permutation_tape(self):
-        """ Test that identity permutations have no effect on tapes. """
+        """Test that identity permutations have no effect on tapes."""
 
         with qml.tape.QuantumTape() as tape:
             qml.templates.Permute([0, "a", "c", "d"], wires=[0, "a", "c", "d"])
@@ -61,7 +61,7 @@ class TestDecomposition:
         ],
     )
     def test_two_cycle_permutations_qnode(self, permutation_order, expected_wires):
-        """ Test some two-cycles on QNodes. """
+        """Test some two-cycles on QNodes."""
 
         dev = qml.device("default.qubit", wires=len(permutation_order))
 
@@ -92,7 +92,7 @@ class TestDecomposition:
         ],
     )
     def test_two_cycle_permutations_tape(self, permutation_order, wire_order, expected_wires):
-        """ Test some two-cycles on tapes. """
+        """Test some two-cycles on tapes."""
 
         with qml.tape.QuantumTape() as tape:
             qml.templates.Permute(permutation_order, wire_order)
@@ -113,7 +113,7 @@ class TestDecomposition:
         ],
     )
     def test_cyclic_permutations_qnode(self, permutation_order, expected_wires):
-        """ Test more general cycles on QNodes. """
+        """Test more general cycles on QNodes."""
 
         dev = qml.device("default.qubit", wires=len(permutation_order))
 
@@ -140,7 +140,7 @@ class TestDecomposition:
         ],
     )
     def test_cyclic_permutations_tape(self, permutation_order, wire_order, expected_wires):
-        """ Test more general cycles on tapes. """
+        """Test more general cycles on tapes."""
 
         with qml.tape.QuantumTape() as tape:
             qml.templates.Permute(permutation_order, wire_order)
@@ -161,7 +161,7 @@ class TestDecomposition:
         ],
     )
     def test_arbitrary_permutations_qnode(self, permutation_order, expected_wires):
-        """ Test arbitrarily generated permutations on QNodes. """
+        """Test arbitrarily generated permutations on QNodes."""
 
         dev = qml.device("default.qubit", wires=len(permutation_order))
 
@@ -196,7 +196,7 @@ class TestDecomposition:
         ],
     )
     def test_arbitrary_permutations_tape(self, permutation_order, wire_order, expected_wires):
-        """ Test arbitrarily generated permutations on tapes. """
+        """Test arbitrarily generated permutations on tapes."""
 
         with qml.tape.QuantumTape() as tape:
             qml.templates.Permute(permutation_order, wire_order)
@@ -219,7 +219,7 @@ class TestDecomposition:
     def test_subset_permutations_qnode(
         self, num_wires, permutation_order, wire_subset, expected_wires
     ):
-        """ Test permutation of wire subsets on QNodes. """
+        """Test permutation of wire subsets on QNodes."""
 
         dev = qml.device("default.qubit", wires=num_wires)
 
@@ -253,7 +253,7 @@ class TestDecomposition:
     def test_subset_permutations_tape(
         self, wire_labels, permutation_order, wire_subset, expected_wires
     ):
-        """ Test permutation of wire subsets on tapes. """
+        """Test permutation of wire subsets on tapes."""
 
         with qml.tape.QuantumTape() as tape:
             # Make sure all the wires are actually there
diff --git a/tests/test_operation.py b/tests/test_operation.py
index 34437c5e8..29ed19170 100644
--- a/tests/test_operation.py
+++ b/tests/test_operation.py
@@ -459,7 +459,7 @@ class TestObservableConstruction:
 
 
 class TestOperatorIntegration:
-    """ Integration tests for the Operator class"""
+    """Integration tests for the Operator class"""
 
     def test_all_wires_defined_but_init_with_one(self):
         """Test that an exception is raised if the class is defined with ALL wires,
@@ -486,7 +486,7 @@ class TestOperatorIntegration:
 
 
 class TestOperationIntegration:
-    """ Integration tests for the Operation class"""
+    """Integration tests for the Operation class"""
 
     def test_inverse_of_operation(self):
         """Test the inverse of an operation"""
diff --git a/tests/test_qubit_device.py b/tests/test_qubit_device.py
index 59737a09b..8973a4ec1 100644
--- a/tests/test_qubit_device.py
+++ b/tests/test_qubit_device.py
@@ -35,7 +35,7 @@ mock_qubit_device_rotations = ["RX", "RY", "RZ"]
 
 @pytest.fixture(scope="function")
 def mock_qubit_device(monkeypatch):
-    """ A function to create a mock device that mocks most of the methods except for e.g. probability()"""
+    """A function to create a mock device that mocks most of the methods except for e.g. probability()"""
     with monkeypatch.context() as m:
         m.setattr(QubitDevice, "__abstractmethods__", frozenset())
         m.setattr(QubitDevice, "_capabilities", mock_qubit_device_capabilities)