Repository: PennyLaneAI/pennylane (python)

Issue:
Implement labels for broadcasted operators
### Feature details

When using parameter broadcasting and creating the label of an operation, its data is perceived as a matrix by PennyLane and therefore represented only symbolically:
```pycon
>>> @qml.qnode(dev)
>>> def qnode(x):
>>>     qml.RY(x, 0)
>>>     return qml.expval(qml.PauliZ(0))
>>> qml.draw(qnode)(np.array(0.5))
'0: ──RY(0.50)─┤  <Z>'
>>> qml.draw(qnode)(np.array([0.5, 0.9]))
'0: ──RY(M0)─┤  <Z>'
```
For large broadcasting dimensions this is definitely reasonable, as otherwise large arrays would be printed in circuit drawings, cluttering the drawing. However, for small broadcasting dimensions, like the two shifts of Pauli rotation parameter-shift rules, it would be useful to print out the broadcasted parameters explicitly.

### Implementation

One could
1. Decide for a cut-off size of the broadcasting axis and "simply" implement parameter printing for smaller data and symbolic printing (like `M0` above) for larger data; or
2. as tapes with broadcasted parameters have a unique `batch_size`, one could print out _multiple_ tapes, one for each value of the broadcasted parameter(s) (and the other ones being constant, of course). Again, there probably should be an upper limit as to how many tapes are drawn at most.

### How important would you say this feature is?

1: Not important. Would be nice to have.

### Additional information

The priority of this is lowered due to broadcasting being used mostly internally until now.

Pull request description:
Draw matrices by default
**Context:**
Currently, matrix-valued parameters are not drawn by default.

**Description of the Change:**
This PR changes the default of `show_matrices` to `True`.

**Benefits:**
This is expected to be convenient in particular for broadcasted tapes.
Also: Test linting.

**Possible Drawbacks:**

**Related GitHub Issues:**
closes #2641 

- [x] Change docstring outputs or explicitly set `show_matrices=False` where applicable.

Patch:
diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md
index a941142c3..399a6c8ab 100644
--- a/doc/releases/changelog-dev.md
+++ b/doc/releases/changelog-dev.md
@@ -70,6 +70,10 @@
   the hash of any operators/measurement processes.
   [(#4087)](https://github.com/PennyLaneAI/pennylane/pull/4087)
 
+* All drawing methods changed their default value for the keyword argument `show_matrices`
+  to `True`. This allows quick insights into broadcasted tapes for example.
+  [(#3920)](https://github.com/PennyLaneAI/pennylane/pull/3920)
+
 * Support for adjoint differentiation has been added to the `DefaultQubit2` device.
   [(#4037)](https://github.com/PennyLaneAI/pennylane/pull/4037)
 
@@ -118,6 +122,9 @@
 
 <h3>Breaking changes 💔</h3>
 
+* All drawing methods changed their default value for the keyword argument `show_matrices` to `True`.
+  [(#3920)](https://github.com/PennyLaneAI/pennylane/pull/3920)
+
 * `DiagonalQubitUnitary` does not decompose into `QubitUnitary` any longer, but into `RZ`, `IsingZZ`
   and `MultiRZ` gates.
   [(#4035)](https://github.com/PennyLaneAI/pennylane/pull/4035)
@@ -161,7 +168,7 @@ This release contains contributions from (in alphabetical order):
 Isaac De Vlugt,
 Soran Jahangiri,
 Edward Jiang,
-Korbinian Kottmann
+Korbinian Kottmann,
 Christina Lee,
 Vincent Michaud-Rioux,
 Romain Moyard,
diff --git a/pennylane/drawer/draw.py b/pennylane/drawer/draw.py
index a73b8fe17..ae7c0bf53 100644
--- a/pennylane/drawer/draw.py
+++ b/pennylane/drawer/draw.py
@@ -30,7 +30,7 @@ def draw(
     show_all_wires=False,
     decimals=2,
     max_length=100,
-    show_matrices=False,
+    show_matrices=True,
     expansion_strategy=None,
 ):
     """Create a function that draws the given qnode or quantum function.
@@ -100,15 +100,15 @@ def draw(
     >>> print(qml.draw(circuit2)("x"))
     0: ──RX(x)─┤  <Z>
 
-    When requested with ``show_matrices=True``, matrix valued parameters are printed below the
-    circuit:
+    When requested with ``show_matrices=True`` (the default), matrix valued parameters
+    are printed below the circuit. For ``show_matrices=False``, they are not printed:
 
     >>> @qml.qnode(qml.device('default.qubit', wires=2))
     ... def circuit3():
     ...     qml.QubitUnitary(np.eye(2), wires=0)
     ...     qml.QubitUnitary(-np.eye(4), wires=(0,1))
     ...     return qml.expval(qml.Hermitian(np.eye(2), wires=1))
-    >>> print(qml.draw(circuit3, show_matrices=True)())
+    >>> print(qml.draw(circuit3)())
     0: ──U(M0)─╭U(M1)─┤
     1: ────────╰U(M1)─┤  <𝓗(M0)>
     M0 =
@@ -119,6 +119,9 @@ def draw(
     [-0. -1. -0. -0.]
     [-0. -0. -1. -0.]
     [-0. -0. -0. -1.]]
+    >>> print(qml.draw(circuit3, show_matrices=False)())
+    0: ──U(M0)─╭U(M1)─┤
+    1: ────────╰U(M1)─┤  <𝓗(M0)>
 
     The ``max_length`` keyword warps long circuits:
 
@@ -232,7 +235,7 @@ def _draw_qnode(
     show_all_wires=False,
     decimals=2,
     max_length=100,
-    show_matrices=False,
+    show_matrices=True,
     expansion_strategy=None,
 ):
     @wraps(qnode)
@@ -261,10 +264,12 @@ def _draw_qnode(
                 )
                 for t in tapes[0]
             ]
-            if show_matrices:
-                mat_str = "\n"
+            if show_matrices and cache["matrices"]:
+                mat_str = ""
                 for i, mat in enumerate(cache["matrices"]):
                     mat_str += f"\nM{i} = \n{mat}"
+                if mat_str:
+                    mat_str = "\n" + mat_str
                 return "\n\n".join(res) + mat_str
             return "\n\n".join(res)
 
diff --git a/pennylane/drawer/tape_text.py b/pennylane/drawer/tape_text.py
index 6d9f6fe37..b292e0376 100644
--- a/pennylane/drawer/tape_text.py
+++ b/pennylane/drawer/tape_text.py
@@ -101,7 +101,7 @@ def tape_text(
     show_all_wires=False,
     decimals=None,
     max_length=100,
-    show_matrices=False,
+    show_matrices=True,
     cache=None,
 ):
     """Text based diagram for a Quantum Tape.
@@ -116,7 +116,7 @@ def tape_text(
             Default ``None`` will omit parameters from operation labels.
         max_length (Int) : Maximum length of a individual line.  After this length, the diagram will
             begin anew beneath the previous lines.
-        show_matrices=False (bool): show matrix valued parameters below all circuit diagrams
+        show_matrices=True (bool): show matrix valued parameters below all circuit diagrams
         cache (dict): Used to store information between recursive calls. Necessary keys are ``'tape_offset'``
             and ``'matrices'``.
 
@@ -204,7 +204,7 @@ def tape_text(
 
     Matrix valued parameters are always denoted by ``M`` followed by an integer corresponding to
     unique matrices.  The list of unique matrices can be printed at the end of the diagram by
-    selecting ``show_matrices=True``:
+    selecting ``show_matrices=True`` (the default):
 
     .. code-block:: python
 
@@ -213,7 +213,7 @@ def tape_text(
             qml.QubitUnitary(np.eye(2), wires=1)
             qml.expval(qml.Hermitian(np.eye(4), wires=(0,1)))
 
-    >>> print(qml.drawer.tape_text(tape, show_matrices=True))
+    >>> print(qml.drawer.tape_text(tape))
     0: ──U(M0)─┤ ╭<𝓗(M1)>
     1: ──U(M0)─┤ ╰<𝓗(M1)>
     M0 =
@@ -230,7 +230,7 @@ def tape_text(
     tape offset.
 
     >>> cache = {'matrices': [-np.eye(3)]}
-    >>> print(qml.drawer.tape_text(tape, show_matrices=True, cache=cache))
+    >>> print(qml.drawer.tape_text(tape, cache=cache))
     0: ──U(M1)─┤ ╭<𝓗(M2)>
     1: ──U(M1)─┤ ╰<𝓗(M2)>
     M0 =
@@ -332,6 +332,7 @@ def tape_text(
             totals = [filler.join([t, s]) for t, s in zip(totals, layer_str)]
         if ender:
             totals = [s + "─┤" for s in totals]
+            line_length += 2
 
     # Recursively handle nested tapes #
     tape_totals = "\n".join(finished_lines + totals)
diff --git a/pennylane/ops/op_math/controlled_decompositions.py b/pennylane/ops/op_math/controlled_decompositions.py
index b414c70d6..c4f8cf247 100644
--- a/pennylane/ops/op_math/controlled_decompositions.py
+++ b/pennylane/ops/op_math/controlled_decompositions.py
@@ -397,7 +397,7 @@ def ctrl_decomp_bisect(
     **Example:**
 
     >>> op = qml.T(0) # uses OD algorithm
-    >>> print(qml.draw(ctrl_decomp_bisect, wire_order=(0,1,2,3,4,5))(op, (1,2,3,4,5)))
+    >>> print(qml.draw(ctrl_decomp_bisect, wire_order=(0,1,2,3,4,5), show_matrices=False)(op, (1,2,3,4,5)))
     0: ─╭X──U(M0)─╭X──U(M0)†─╭X──U(M0)─╭X──U(M0)†─┤
     1: ─├●────────│──────────├●────────│──────────┤
     2: ─├●────────│──────────├●────────│──────────┤
@@ -405,7 +405,7 @@ def ctrl_decomp_bisect(
     4: ───────────├●───────────────────├●─────────┤
     5: ───────────╰●───────────────────╰●─────────┤
     >>> op = qml.QubitUnitary([[0,1j],[1j,0]], 0) # uses MD algorithm
-    >>> print(qml.draw(ctrl_decomp_bisect, wire_order=(0,1,2,3,4,5))(op, (1,2,3,4,5)))
+    >>> print(qml.draw(ctrl_decomp_bisect, wire_order=(0,1,2,3,4,5), show_matrices=False)(op, (1,2,3,4,5)))
     0: ──H─╭X──U(M0)─╭X──U(M0)†─╭X──U(M0)─╭X──U(M0)†──H─┤
     1: ────├●────────│──────────├●────────│─────────────┤
     2: ────├●────────│──────────├●────────│─────────────┤
@@ -413,7 +413,7 @@ def ctrl_decomp_bisect(
     4: ──────────────├●───────────────────├●────────────┤
     5: ──────────────╰●───────────────────╰●────────────┤
     >>> op = qml.Hadamard(0) # uses general algorithm
-    >>> print(qml.draw(ctrl_decomp_bisect, wire_order=(0,1,2,3,4,5))(op, (1,2,3,4,5)))
+    >>> print(qml.draw(ctrl_decomp_bisect, wire_order=(0,1,2,3,4,5), show_matrices=False)(op, (1,2,3,4,5)))
     0: ──U(M0)─╭X──U(M1)†──U(M2)─╭X──U(M2)†─╭X──U(M2)─╭X──U(M2)†─╭X──U(M1)─╭X──U(M0)─┤
     1: ────────│─────────────────│──────────├●────────│──────────├●────────│─────────┤
     2: ────────│─────────────────│──────────├●────────│──────────├●────────│─────────┤
diff --git a/pennylane/optimize/adaptive.py b/pennylane/optimize/adaptive.py
index d24ea2d67..4676c9fe6 100644
--- a/pennylane/optimize/adaptive.py
+++ b/pennylane/optimize/adaptive.py
@@ -100,7 +100,7 @@ class AdaptiveOptimizer:
     >>> for i in range(len(operator_pool)):
     ...     circuit, energy, gradient = opt.step_and_cost(circuit, operator_pool, drain_pool=True)
     ...     print('Energy:', energy)
-    ...     print(qml.draw(circuit)())
+    ...     print(qml.draw(circuit, show_matrices=False)())
     ...     print('Largest Gradient:', gradient)
     ...     print()
     ...     if gradient < 1e-3:
diff --git a/pennylane/tape/qscript.py b/pennylane/tape/qscript.py
index 87e978b0a..72a2fadac 100644
--- a/pennylane/tape/qscript.py
+++ b/pennylane/tape/qscript.py
@@ -1247,7 +1247,7 @@ class QuantumScript:
         show_all_wires=False,
         decimals=None,
         max_length=100,
-        show_matrices=False,
+        show_matrices=True,
     ):
         """Draw the quantum script as a circuit diagram. See :func:`~.drawer.tape_text` for more information.
 
@@ -1258,7 +1258,7 @@ class QuantumScript:
                 Default ``None`` will omit parameters from operation labels.
             max_length (Int) : Maximum length of a individual line.  After this length, the diagram will
                 begin anew beneath the previous lines.
-            show_matrices=False (bool): show matrix valued parameters below all circuit diagrams
+            show_matrices=True (bool): show matrix valued parameters below all circuit diagrams
 
         Returns:
             str: the circuit representation of the quantum script
diff --git a/pennylane/templates/embeddings/displacement.py b/pennylane/templates/embeddings/displacement.py
index caf83c7f1..f7f0957d6 100644
--- a/pennylane/templates/embeddings/displacement.py
+++ b/pennylane/templates/embeddings/displacement.py
@@ -67,7 +67,7 @@ class DisplacementEmbedding(Operation):
 
         And, the resulting circuit is:
 
-        >>> print(qml.draw(circuit)(X))
+        >>> print(qml.draw(circuit, show_matrices=False)(X))
         0: ─╭DisplacementEmbedding(M0)──────────┤
         1: ─├DisplacementEmbedding(M0)──P(0.10)─┤  <n>
         2: ─╰DisplacementEmbedding(M0)──────────┤
@@ -91,7 +91,7 @@ class DisplacementEmbedding(Operation):
 
         And, the resulting circuit is:
 
-        >>> print(qml.draw(circuit)(X))
+        >>> print(qml.draw(circuit, show_matrices=False)(X))
         0: ─╭DisplacementEmbedding(M0)──────────┤
         1: ─├DisplacementEmbedding(M0)──P(0.10)─┤  <n>
         2: ─╰DisplacementEmbedding(M0)──────────┤
diff --git a/pennylane/templates/embeddings/squeezing.py b/pennylane/templates/embeddings/squeezing.py
index 35a88fc63..124b3070e 100644
--- a/pennylane/templates/embeddings/squeezing.py
+++ b/pennylane/templates/embeddings/squeezing.py
@@ -68,7 +68,7 @@ class SqueezingEmbedding(Operation):
 
         And, the resulting circuit is:
 
-        >>> print(qml.draw(circuit)(X))
+        >>> print(qml.draw(circuit, show_matrices=False)(X))
         0: ─╭SqueezingEmbedding(M0)──────────┤
         1: ─├SqueezingEmbedding(M0)──P(0.10)─┤  <n>
         2: ─╰SqueezingEmbedding(M0)──────────┤
@@ -92,7 +92,7 @@ class SqueezingEmbedding(Operation):
 
         And, the resulting circuit is:
 
-        >>> print(qml.draw(circuit)(X))
+        >>> print(qml.draw(circuit, show_matrices=False)(X))
         0: ─╭SqueezingEmbedding(M0)──────────┤
         1: ─├SqueezingEmbedding(M0)──P(0.10)─┤  <n>
         2: ─╰SqueezingEmbedding(M0)──────────┤
diff --git a/pennylane/templates/swapnetworks/ccl2.py b/pennylane/templates/swapnetworks/ccl2.py
index 97bed6a6a..07be3dfef 100644
--- a/pennylane/templates/swapnetworks/ccl2.py
+++ b/pennylane/templates/swapnetworks/ccl2.py
@@ -47,7 +47,7 @@ class TwoLocalSwapNetwork(Operation):
         ... def swap_network_circuit():
         ...    qml.templates.TwoLocalSwapNetwork(dev.wires, acquaintances, fermionic=True, shift=False)
         ...    return qml.state()
-        >>> qml.draw(swap_network_circuit, expansion_strategy = 'device')()
+        >>> qml.draw(swap_network_circuit, expansion_strategy='device')()
         0: ─╭●─╭fSWAP(3.14)─────────────────╭●─╭fSWAP(3.14)─────────────────╭●─╭fSWAP(3.14)─┤  State
         1: ─╰X─╰fSWAP(3.14)─╭●─╭fSWAP(3.14)─╰X─╰fSWAP(3.14)─╭●─╭fSWAP(3.14)─╰X─╰fSWAP(3.14)─┤  State
         2: ─╭●─╭fSWAP(3.14)─╰X─╰fSWAP(3.14)─╭●─╭fSWAP(3.14)─╰X─╰fSWAP(3.14)─╭●─╭fSWAP(3.14)─┤  State
@@ -72,7 +72,7 @@ class TwoLocalSwapNetwork(Operation):
             ... def swap_network_circuit():
             ...    qml.templates.TwoLocalSwapNetwork(dev.wires, acquaintances, weights, fermionic=False)
             ...    return qml.state()
-            >>> qml.draw(swap_network_circuit, expansion_strategy = 'device')()
+            >>> qml.draw(swap_network_circuit, expansion_strategy='device')()
             0: ─╭●────────╭SWAP─────────────────╭●────────╭SWAP─────────────────╭●────────╭SWAP─┤  State
             1: ─╰RY(0.20)─╰SWAP─╭●────────╭SWAP─╰RY(0.09)─╰SWAP─╭●────────╭SWAP─╰RY(0.62)─╰SWAP─┤  State
             2: ─╭●────────╭SWAP─╰RY(0.68)─╰SWAP─╭●────────╭SWAP─╰RY(0.34)─╰SWAP─╭●────────╭SWAP─┤  State
diff --git a/pennylane/templates/tensornetworks/mera.py b/pennylane/templates/tensornetworks/mera.py
index 62d057f70..86490fb0d 100644
--- a/pennylane/templates/tensornetworks/mera.py
+++ b/pennylane/templates/tensornetworks/mera.py
@@ -157,7 +157,7 @@ class MERA(Operation):
 
         It may be necessary to reorder the wires to see the MERA architecture clearly:
 
-        >>> print(qml.draw(circuit,expansion_strategy='device',wire_order=[2,0,1,3])(template_weights))
+        >>> print(qml.draw(circuit, expansion_strategy='device', wire_order=[2,0,1,3])(template_weights))
         2: ───────────────╭●──RY(0.10)──╭X──RY(-0.30)───────────────┤
         0: ─╭X──RY(-0.30)─│─────────────╰●──RY(0.10)──╭●──RY(0.10)──┤
         1: ─╰●──RY(0.10)──│─────────────╭X──RY(-0.30)─╰X──RY(-0.30)─┤  <Z>
diff --git a/pennylane/templates/tensornetworks/mps.py b/pennylane/templates/tensornetworks/mps.py
index f7b93e091..bd0149de8 100644
--- a/pennylane/templates/tensornetworks/mps.py
+++ b/pennylane/templates/tensornetworks/mps.py
@@ -110,7 +110,7 @@ class MPS(Operation):
                 qml.MPS(range(n_wires),n_block_wires,block, n_params_block, template_weights)
                 return qml.expval(qml.PauliZ(wires=n_wires-1))
 
-        >>> print(qml.draw(circuit,expansion_strategy='device')(template_weights))
+        >>> print(qml.draw(circuit, expansion_strategy='device')(template_weights))
         0: ─╭●──RY(0.10)──────────────────────────────┤
         1: ─╰X──RY(-0.30)─╭●──RY(0.10)────────────────┤
         2: ───────────────╰X──RY(-0.30)─╭●──RY(0.10)──┤
diff --git a/pennylane/templates/tensornetworks/ttn.py b/pennylane/templates/tensornetworks/ttn.py
index bd7c28130..f876b1309 100644
--- a/pennylane/templates/tensornetworks/ttn.py
+++ b/pennylane/templates/tensornetworks/ttn.py
@@ -142,7 +142,7 @@ class TTN(Operation):
                 qml.TTN(range(n_wires),n_block_wires,block, n_params_block, template_weights)
                 return qml.expval(qml.PauliZ(wires=n_wires-1))
 
-        >>> print(qml.draw(circuit,expansion_strategy='device')(template_weights))
+        >>> print(qml.draw(circuit, expansion_strategy='device')(template_weights))
         0: ─╭●──RY(0.10)────────────────┤
         1: ─╰X──RY(-0.30)─╭●──RY(0.10)──┤
         2: ─╭●──RY(0.10)──│─────────────┤
diff --git a/pennylane/transforms/optimization/merge_amplitude_embedding.py b/pennylane/transforms/optimization/merge_amplitude_embedding.py
index fc6fff9fd..8a82c88e3 100644
--- a/pennylane/transforms/optimization/merge_amplitude_embedding.py
+++ b/pennylane/transforms/optimization/merge_amplitude_embedding.py
@@ -49,7 +49,7 @@ def merge_amplitude_embedding(tape):
     >>> dev = qml.device('default.qubit', wires=4)
     >>> optimized_qfunc = qml.transforms.merge_amplitude_embedding(qfunc)
     >>> optimized_qnode = qml.QNode(optimized_qfunc, dev)
-    >>> print(qml.draw(optimized_qnode, show_matrices=True)())
+    >>> print(qml.draw(optimized_qnode)())
     0: ─╭●──────────────────────┤  State
     1: ─╰X──────────────────────┤  State
     2: ─╭AmplitudeEmbedding(M0)─┤  State
diff --git a/pennylane/transforms/unitary_to_rot.py b/pennylane/transforms/unitary_to_rot.py
index 2f3cfa4c7..873044f49 100644
--- a/pennylane/transforms/unitary_to_rot.py
+++ b/pennylane/transforms/unitary_to_rot.py
@@ -63,7 +63,7 @@ def unitary_to_rot(tape):
 
     >>> dev = qml.device('default.qubit', wires=1)
     >>> qnode = qml.QNode(qfunc, dev)
-    >>> print(qml.draw(qnode, show_matrices=True)())
+    >>> print(qml.draw(qnode)())
     0: ──U(M0)─┤  <Z>
     M0 =
     [[-0.17111489+0.58564875j -0.69352236-0.38309524j]


Test patch:
diff --git a/tests/drawer/test_draw.py b/tests/drawer/test_draw.py
index f6c0b43e1..c9c79bbfc 100644
--- a/tests/drawer/test_draw.py
+++ b/tests/drawer/test_draw.py
@@ -14,6 +14,7 @@
 """
 Integration tests for the draw transform
 """
+# pylint: disable=import-outside-toplevel
 from functools import partial
 
 import pytest
@@ -25,6 +26,7 @@ from pennylane.drawer import draw
 
 @qml.qnode(qml.device("default.qubit", wires=(0, "a", 1.234)))
 def circuit(x, y, z):
+    """A quantum circuit on three wires."""
     qml.RX(x, wires=0)
     qml.RY(y, wires="a")
     qml.RZ(z, wires=1.234)
@@ -54,10 +56,10 @@ class TestLabelling:
         """Test show_all_wires=True forces empty wires to display."""
 
         @qml.qnode(qml.device("default.qubit", wires=(0, 1)))
-        def circuit():
+        def circ():
             return qml.expval(qml.PauliZ(0))
 
-        split_str = draw(circuit, show_all_wires=True)().split("\n")
+        split_str = draw(circ, show_all_wires=True)().split("\n")
         assert split_str[0][:2] == "0:"
         assert split_str[1][:2] == "1:"
 
@@ -65,10 +67,10 @@ class TestLabelling:
         """Test show_all_wires forces empty wires to display when empty wire is in wire order."""
 
         @qml.qnode(qml.device("default.qubit", wires=1))
-        def circuit():
+        def circ():
             return qml.expval(qml.PauliZ(0))
 
-        split_str = draw(circuit, wire_order=[0, "a"], show_all_wires=True)().split("\n")
+        split_str = draw(circ, wire_order=[0, "a"], show_all_wires=True)().split("\n")
         assert split_str[0][:2] == "0:"
         assert split_str[1][:2] == "a:"
 
@@ -98,12 +100,12 @@ class TestDecimals:
         """Test decimals also displays parameters when the operation has multiple parameters."""
 
         @qml.qnode(qml.device("default.qubit", wires=(0)))
-        def circuit(x):
+        def circ(x):
             qml.Rot(*x, wires=0)
             return qml.expval(qml.PauliZ(0))
 
         expected = "0: ──Rot(1.2,2.3,3.5)─┤  <Z>"
-        assert draw(circuit, decimals=1)([1.234, 2.345, 3.456]) == expected
+        assert draw(circ, decimals=1)([1.234, 2.345, 3.456]) == expected
 
     def test_decimals_0(self):
         """Test decimals=0 rounds to integers."""
@@ -153,6 +155,8 @@ class TestDecimals:
 
 
 class TestMatrixParameters:
+    """Test that tapes containing matrix-valued parameters are drawn correctly."""
+
     def test_matrix_parameters(self):
         """Test matrix valued parameters remembered and printed out upon request."""
 
@@ -167,7 +171,7 @@ class TestMatrixParameters:
             "1: ─╰QubitStateVector(M0)────────┤         "
         )
 
-        assert draw(matrices_circuit)() == expected1
+        assert draw(matrices_circuit, show_matrices=False)() == expected1
 
         expected2 = (
             "0: ─╭QubitStateVector(M0)──U(M1)─┤  <𝓗(M1)>\n"
@@ -176,7 +180,7 @@ class TestMatrixParameters:
             "M1 = \n[[1. 0.]\n [0. 1.]]"
         )
 
-        assert draw(matrices_circuit, show_matrices=True)() == expected2
+        assert draw(matrices_circuit)() == expected2
 
     def test_matrix_parameters_batch_transform(self):
         """Test matrix parameters only printed once after a batch transform."""
@@ -193,20 +197,21 @@ class TestMatrixParameters:
             "0: ─╭QubitStateVector(M0)──U(M1)────┤         \n"
             "1: ─╰QubitStateVector(M0)──RX(1.20)─┤  <𝓗(M1)>\n\n"
             "0: ─╭QubitStateVector(M0)──U(M1)────┤         \n"
-            "1: ─╰QubitStateVector(M0)──RX(0.80)─┤  <𝓗(M1)>"
+            "1: ─╰QubitStateVector(M0)──RX(0.80)─┤  <𝓗(M1)>\n\n"
+            "M0 = \n[1. 0. 0. 0.]\n"
+            "M1 = \n[[1. 0.]\n [0. 1.]]"
         )
-
-        assert draw(matrices_circuit)(np.array(1.0, requires_grad=True))
+        output = draw(matrices_circuit)(np.array(1.0, requires_grad=True))
+        assert output == expected1
 
         expected2 = (
             "0: ─╭QubitStateVector(M0)──U(M1)────┤         \n"
             "1: ─╰QubitStateVector(M0)──RX(1.20)─┤  <𝓗(M1)>\n\n"
             "0: ─╭QubitStateVector(M0)──U(M1)────┤         \n"
-            "1: ─╰QubitStateVector(M0)──RX(0.80)─┤  <𝓗(M1)>\n\n"
-            "M0 = \n[1.0, 0.0, 0.0, 0.0]\n"
-            "M1 = \n[[1. 0.]\n [0. 1.]]"
+            "1: ─╰QubitStateVector(M0)──RX(0.80)─┤  <𝓗(M1)>"
         )
-        assert draw(matrices_circuit, show_matrices=True)(np.array(1.0, requires_grad=True))
+        output = draw(matrices_circuit, show_matrices=False)(np.array(1.0, requires_grad=True))
+        assert output == expected2
 
 
 class TestMaxLength:
@@ -226,6 +231,8 @@ class TestMaxLength:
 
     @pytest.mark.parametrize("ml", [10, 15, 20])
     def test_setting_max_length(self, ml):
+        """Test that setting a maximal length works as expected."""
+
         @qml.qnode(qml.device("default.qubit", wires=1))
         def long_circuit():
             for _ in range(10):
@@ -243,39 +250,40 @@ class TestLayering:
         """Test non-blocking gates end up on same layer."""
 
         @qml.qnode(qml.device("default.qubit", wires=3))
-        def circuit():
-            [qml.PauliX(i) for i in range(3)]
+        def circ():
+            _ = [qml.PauliX(i) for i in range(3)]
             return [qml.expval(qml.PauliZ(i)) for i in range(3)]
 
         expected = "0: ──X─┤  <Z>\n1: ──X─┤  <Z>\n2: ──X─┤  <Z>"
-        assert draw(circuit)() == expected
+        assert draw(circ)() == expected
 
     def test_blocking_ops(self):
         """Test single qubits gates on the same wire block each other."""
 
         @qml.qnode(qml.device("default.qubit", wires=1))
-        def circuit():
-            [qml.PauliX(0) for i in range(3)]
+        def circ():
+            _ = [qml.PauliX(0) for i in range(3)]
             return qml.expval(qml.PauliZ(0))
 
         expected = "0: ──X──X──X─┤  <Z>"
+        assert draw(circ)() == expected
 
     def test_blocking_multiwire_gate(self):
         """Test gate gets blocked by multi-wire gate."""
 
         @qml.qnode(qml.device("default.qubit", wires=3))
-        def circuit():
+        def circ():
             qml.PauliX(0)
             qml.IsingXX(1.234, wires=(0, 2))
             qml.PauliX(1)
             return qml.expval(qml.PauliZ(0))
 
-        expect = (
+        expected = (
             "0: ──X─╭IsingXX(1.23)────┤  <Z>\n"
             "1: ────│───────────────X─┤     \n"
             "2: ────╰IsingXX(1.23)────┤     "
         )
-        assert draw(circuit)() == expect
+        assert draw(circ)() == expected
 
 
 @pytest.mark.parametrize(
@@ -290,13 +298,13 @@ def test_draw_batch_transform(transform):
 
     @transform
     @qml.qnode(qml.device("default.qubit", wires=1))
-    def circuit(x):
+    def circ(x):
         qml.Hadamard(wires=0)
         qml.RX(x, wires=0)
         return qml.expval(qml.PauliZ(0))
 
     expected = "0: ──H──RX(0.8)─┤  <Z>\n\n0: ──H──RX(0.4)─┤  <Z>"
-    assert draw(circuit, decimals=1)(np.array(0.6, requires_grad=True)) == expected
+    assert draw(circ, decimals=1)(np.array(0.6, requires_grad=True)) == expected
 
 
 @pytest.mark.skip("Nested tapes are being deprecated")
@@ -304,19 +312,15 @@ def test_nested_tapes():
     """Test nested tapes inside the qnode."""
 
     @qml.qnode(qml.device("default.qubit", wires=1))
-    def circuit():
-        with qml.queuing.AnnotatedQueue() as q_tape1:
+    def circ():
+        with qml.queuing.AnnotatedQueue():
             qml.PauliX(0)
-            with qml.queuing.AnnotatedQueue() as q_tape2:
+            with qml.queuing.AnnotatedQueue():
                 qml.PauliY(0)
-            tape2 = qml.tape.QuantumScript.from_queue(q_tape2)
-        tape1 = qml.tape.QuantumScript.from_queue(q_tape1)
-        with qml.queuing.AnnotatedQueue() as q_tape3:
+        with qml.queuing.AnnotatedQueue():
             qml.PauliZ(0)
-            with qml.queuing.AnnotatedQueue() as q_tape4:
+            with qml.queuing.AnnotatedQueue():
                 qml.PauliX(0)
-            tape4 = qml.tape.QuantumScript.from_queue(q_tape4)
-        tape3 = qml.tape.QuantumScript.from_queue(q_tape3)
         return qml.expval(qml.PauliZ(0))
 
     expected = (
@@ -327,7 +331,7 @@ def test_nested_tapes():
         "Tape:3\n0: ──X─┤  "
     )
 
-    assert draw(circuit)() == expected
+    assert draw(circ)() == expected
 
 
 def test_expansion_strategy():
@@ -336,15 +340,15 @@ def test_expansion_strategy():
     H = qml.PauliX(0) + qml.PauliZ(1) + 0.5 * qml.PauliX(0) @ qml.PauliX(1)
 
     @qml.qnode(qml.device("default.qubit", wires=2))
-    def circuit(t):
+    def circ(t):
         qml.ApproxTimeEvolution(H, t, 2)
         return qml.probs(wires=0)
 
     expected_gradient = "0: ─╭ApproxTimeEvolution─┤  Probs\n1: ─╰ApproxTimeEvolution─┤       "
-    assert draw(circuit, expansion_strategy="gradient", decimals=None)(0.5) == expected_gradient
+    assert draw(circ, expansion_strategy="gradient", decimals=None)(0.5) == expected_gradient
 
     expected_device = "0: ──RX─╭RXX──RX─╭RXX─┤  Probs\n1: ──RZ─╰RXX──RZ─╰RXX─┤       "
-    assert draw(circuit, expansion_strategy="device", decimals=None)(0.5) == expected_device
+    assert draw(circ, expansion_strategy="device", decimals=None)(0.5) == expected_device
 
 
 def test_draw_with_qfunc():
diff --git a/tests/drawer/test_draw_mpl.py b/tests/drawer/test_draw_mpl.py
index 507b1d0ff..31f1c7b90 100644
--- a/tests/drawer/test_draw_mpl.py
+++ b/tests/drawer/test_draw_mpl.py
@@ -30,6 +30,7 @@ dev = qml.device("default.qubit", wires=(0, "a", 1.23))
 
 @qml.qnode(dev)
 def circuit1(x, y):
+    """Circuit on three qubits."""
     qml.RX(x, wires=0)
     qml.CNOT(wires=(0, "a"))
     qml.RY(y, wires=1.23)
@@ -38,6 +39,7 @@ def circuit1(x, y):
 
 @qml.qnode(dev)
 def circuit2(x):
+    """Circuit on a single qubit."""
     qml.RX(x, wires=0)
     return qml.expval(qml.PauliZ(0))
 
diff --git a/tests/drawer/test_mpldrawer.py b/tests/drawer/test_mpldrawer.py
index 65953a8fd..a2a9bce4d 100644
--- a/tests/drawer/test_mpldrawer.py
+++ b/tests/drawer/test_mpldrawer.py
@@ -17,6 +17,7 @@ Tests the MPLDrawer.
 See section on "Testing Matplotlib based code" in the "Software Tests"
 page in the developement guide.
 """
+# pylint: disable=protected-access,wrong-import-position
 
 import pytest
 
@@ -27,7 +28,6 @@ from matplotlib.patches import FancyArrow
 
 from pennylane.drawer import MPLDrawer
 from pennylane.math import allclose
-import pennylane
 
 
 class TestInitialization:
@@ -109,6 +109,8 @@ class TestInitialization:
 
 
 class TestLabels:
+    """Test wire labels work as expected."""
+
     def test_labels(self):
         """Tests labels are added"""
 
@@ -449,6 +451,7 @@ class TestCTRL:
         plt.close()
 
     def test_target_x_color(self):
+        """Test the color of target_x."""
         drawer = MPLDrawer(1, 3)
 
         rgba_red = (1, 0, 0, 1)
@@ -508,6 +511,7 @@ class TestCTRL:
         plt.close()
 
     def test_CNOT_color(self):
+        """Tests the color of CNOT."""
         drawer = MPLDrawer(1, 3)
         rgba_red = (1, 0, 0, 1)
         drawer.CNOT(0, (0, 1), options={"color": rgba_red})
diff --git a/tests/drawer/test_style.py b/tests/drawer/test_style.py
index 87d279695..67fa049c2 100644
--- a/tests/drawer/test_style.py
+++ b/tests/drawer/test_style.py
@@ -48,7 +48,7 @@ def test_black_white_style():
     assert plt.rcParams["patch.force_edgecolor"]  # = True
     assert plt.rcParams["lines.color"] == "black"
     assert plt.rcParams["text.color"] == "black"
-    assert plt.rcParams["path.sketch"] == None
+    assert plt.rcParams["path.sketch"] is None
 
     plt.style.use("default")
 
@@ -67,7 +67,7 @@ def test_black_white_style_dark():
     assert plt.rcParams["patch.force_edgecolor"]  # = True
     assert plt.rcParams["lines.color"] == "white"
     assert plt.rcParams["text.color"] == "white"
-    assert plt.rcParams["path.sketch"] == None
+    assert plt.rcParams["path.sketch"] is None
 
     plt.style.use("default")
 
@@ -125,7 +125,7 @@ def test_solarized_light_style():
     assert plt.rcParams["lines.color"] == "#657b83"
     assert plt.rcParams["text.color"] == "#586e75"
     assert plt.rcParams["patch.force_edgecolor"]  # = True
-    assert plt.rcParams["path.sketch"] == None
+    assert plt.rcParams["path.sketch"] is None
 
     plt.style.use("default")
 
@@ -143,7 +143,7 @@ def test_solarized_dark_style():
     assert plt.rcParams["lines.color"] == "#839496"
     assert plt.rcParams["text.color"] == "#2aa198"
     assert plt.rcParams["patch.force_edgecolor"]  # = True
-    assert plt.rcParams["path.sketch"] == None
+    assert plt.rcParams["path.sketch"] is None
 
     plt.style.use("default")
 
diff --git a/tests/drawer/test_tape_mpl.py b/tests/drawer/test_tape_mpl.py
index 75a85ee76..aaf1d604d 100644
--- a/tests/drawer/test_tape_mpl.py
+++ b/tests/drawer/test_tape_mpl.py
@@ -370,6 +370,7 @@ class TestSpecialGates:
         plt.close()
 
     def test_Prod(self):
+        """Test Prod gets correct special call."""
         with qml.queuing.AnnotatedQueue() as q_tape:
             qml.S(0) @ qml.T(0)
 
@@ -439,6 +440,8 @@ class TestControlledGates:
         assert ax.texts[2].get_text() == "RX\n(1.23)"
         plt.close()
 
+    @pytest.mark.filterwarnings("ignore:Specifying control values as a string")
+    @pytest.mark.filterwarnings("ignore:The control_wires keyword will be removed soon")
     def test_control_values_str(self):
         """Test control values get displayed correctly when they are provided as a string."""
 
diff --git a/tests/drawer/test_tape_text.py b/tests/drawer/test_tape_text.py
index 404021683..a18fe1119 100644
--- a/tests/drawer/test_tape_text.py
+++ b/tests/drawer/test_tape_text.py
@@ -14,6 +14,7 @@
 """
 Unit tests for the `pennylane.draw_text` function.
 """
+# pylint: disable=import-outside-toplevel
 
 import pytest
 
@@ -35,6 +36,8 @@ tape = qml.tape.QuantumScript.from_queue(q_tape)
 
 
 class TestHelperFunctions:
+    """Test helper functions for the tape text."""
+
     @pytest.mark.parametrize(
         "op, out",
         [
@@ -44,6 +47,7 @@ class TestHelperFunctions:
         ],
     )
     def test_add_grouping_symbols(self, op, out):
+        """Test private _add_grouping_symbols function renders as expected."""
         assert out == _add_grouping_symbols(op, ["", "", "", ""], default_wire_map)
 
     @pytest.mark.parametrize(
@@ -113,6 +117,8 @@ class TestHelperFunctions:
 
 
 class TestEmptyTapes:
+    """Test that the text for empty tapes is correct."""
+
     def test_empty_tape(self):
         """Test using an empty tape returns a blank string"""
         assert tape_text(QuantumScript()) == ""
@@ -125,6 +131,8 @@ class TestEmptyTapes:
 
 
 class TestLabeling:
+    """Test that wire labels work correctly."""
+
     def test_any_wire_labels(self):
         """Test wire labels with different kinds of objects."""
 
@@ -176,7 +184,7 @@ class TestDecimals:
     def test_decimals_0(self):
         """Test decimals=0 rounds to integers"""
 
-        expected = "    0: ──RX(1)─┤  \n" "    a: ──RY(2)─┤  \n" "1.234: ──RZ(3)─┤  "
+        expected = "    0: ──RX(1)─┤  \n    a: ──RY(2)─┤  \n1.234: ──RZ(3)─┤  "
 
         assert tape_text(tape, decimals=0) == expected
 
@@ -247,12 +255,15 @@ class TestMaxLength:
                 qml.sample()
 
         tape_ml = qml.tape.QuantumScript.from_queue(q_tape_ml)
-        out = tape_text(tape, max_length=ml)
+        out = tape_text(tape_ml, max_length=ml)
         assert max(len(s) for s in out.split("\n")) <= ml
 
 
 single_op_tests_data = [
-    (qml.MultiControlledX([0, 1, 2], 3, "010"), "0: ─╭○─┤  \n1: ─├●─┤  \n2: ─├○─┤  \n3: ─╰X─┤  "),
+    (
+        qml.MultiControlledX(wires=[0, 1, 2, 3], control_values="010"),
+        "0: ─╭○─┤  \n1: ─├●─┤  \n2: ─├○─┤  \n3: ─╰X─┤  ",
+    ),
     (
         qml.ops.op_math.Controlled(qml.PauliY(3), (0, 1, 2), [0, 1, 0]),
         "0: ─╭○─┤  \n1: ─├●─┤  \n2: ─├○─┤  \n3: ─╰Y─┤  ",
@@ -324,11 +335,11 @@ single_op_tests_data = [
 def test_single_ops(op, expected):
     """Tests a variety of different single operation tapes render as expected."""
 
-    with qml.queuing.AnnotatedQueue() as q_tape:
+    with qml.queuing.AnnotatedQueue() as q:
         qml.apply(op)
 
-    tape = qml.tape.QuantumScript.from_queue(q_tape)
-    assert tape_text(tape, decimals=2) == expected
+    _tape = qml.tape.QuantumScript.from_queue(q)
+    assert tape_text(_tape, decimals=2, show_matrices=False) == expected
 
 
 class TestLayering:
@@ -337,37 +348,37 @@ class TestLayering:
     def test_adjacent_ops(self):
         """Test non-blocking gates end up on same layer."""
 
-        with qml.queuing.AnnotatedQueue() as q_tape:
+        with qml.queuing.AnnotatedQueue() as q:
             qml.PauliX(0)
             qml.PauliX(1)
             qml.PauliX(2)
 
-        tape = qml.tape.QuantumScript.from_queue(q_tape)
-        assert tape_text(tape) == "0: ──X─┤  \n1: ──X─┤  \n2: ──X─┤  "
+        _tape = qml.tape.QuantumScript.from_queue(q)
+        assert tape_text(_tape) == "0: ──X─┤  \n1: ──X─┤  \n2: ──X─┤  "
 
     def test_blocking_ops(self):
         """Test single qubit gates on same wire line up."""
 
-        with qml.queuing.AnnotatedQueue() as q_tape:
+        with qml.queuing.AnnotatedQueue() as q:
             qml.PauliX(0)
             qml.PauliX(0)
             qml.PauliX(0)
 
-        tape = qml.tape.QuantumScript.from_queue(q_tape)
-        assert tape_text(tape) == "0: ──X──X──X─┤  "
+        _tape = qml.tape.QuantumScript.from_queue(q)
+        assert tape_text(_tape) == "0: ──X──X──X─┤  "
 
     def test_blocking_multiwire_gate(self):
         """Tests gate gets blocked by multi-wire gate."""
 
-        with qml.queuing.AnnotatedQueue() as q_tape:
+        with qml.queuing.AnnotatedQueue() as q:
             qml.PauliX(0)
             qml.IsingXX(1.2345, wires=(0, 2))
             qml.PauliX(1)
 
-        tape = qml.tape.QuantumScript.from_queue(q_tape)
+        _tape = qml.tape.QuantumScript.from_queue(q)
         expected = "0: ──X─╭IsingXX────┤  \n1: ────│─────────X─┤  \n2: ────╰IsingXX────┤  "
 
-        assert tape_text(tape, wire_order=[0, 1, 2]) == expected
+        assert tape_text(_tape, wire_order=[0, 1, 2]) == expected
 
 
 tape_matrices = qml.tape.QuantumScript(
@@ -380,27 +391,27 @@ tape_matrices = qml.tape.QuantumScript(
 class TestShowMatrices:
     """Test the handling of matrix-valued parameters."""
 
-    def test_default_no_matrix_parameters(self):
+    def test_default_shows_matrix_parameters(self):
         """Test matrices numbered but not included by default."""
 
         expected = (
             "0: ─╭QubitStateVector(M0)──U(M1)─┤  <𝓗(M1)>\n"
-            "1: ─╰QubitStateVector(M0)────────┤         "
+            "1: ─╰QubitStateVector(M0)────────┤         \n"
+            "M0 = \n[1. 0. 0. 0.]\n"
+            "M1 = \n[[1. 0.]\n [0. 1.]]"
         )
 
         assert tape_text(tape_matrices) == expected
 
-    def test_show_matrices(self):
+    def test_do_not_show_matrices(self):
         """Test matrices included when requested."""
 
         expected = (
             "0: ─╭QubitStateVector(M0)──U(M1)─┤  <𝓗(M1)>\n"
-            "1: ─╰QubitStateVector(M0)────────┤         \n"
-            "M0 = \n[1. 0. 0. 0.]\n"
-            "M1 = \n[[1. 0.]\n [0. 1.]]"
+            "1: ─╰QubitStateVector(M0)────────┤         "
         )
 
-        assert tape_text(tape_matrices, show_matrices=True) == expected
+        assert tape_text(tape_matrices, show_matrices=False) == expected
 
     def test_matrix_parameters_provided_cache(self):
         """Providing an existing matrix cache determines numbering order of matrices.
@@ -427,28 +438,28 @@ class TestNestedTapes:
     def test_cache_keyword_tape_offset(self):
         """Test that tape numbering is determined by the `tape_offset` keyword of the cache."""
 
-        with QuantumTape() as tape:
-            with QuantumTape() as tape_inner:
+        with QuantumTape() as _tape:
+            with QuantumTape():
                 qml.PauliX(0)
 
-        expected = "0: ──Tape:3─┤  \n" "\nTape:3\n" "0: ──X─┤  "
+        expected = "0: ──Tape:3─┤  \n\nTape:3\n0: ──X─┤  "
 
-        assert tape_text(tape, cache={"tape_offset": 3}) == expected
+        assert tape_text(_tape, cache={"tape_offset": 3}) == expected
 
     def test_multiple_nested_tapes(self):
         """Test numbers consistent with multiple nested tapes and
         multiple levels of nesting."""
 
-        with QuantumTape() as tape:
+        with QuantumTape() as _tape:
             qml.PauliX(0)
-            with QuantumTape() as tape0:
+            with QuantumTape():
                 qml.PauliY(0)
                 qml.PauliZ(0)
-                with QuantumTape() as tape2:
+                with QuantumTape():
                     qml.PauliX(0)
-            with QuantumTape() as tape1:
+            with QuantumTape():
                 qml.PauliY(0)
-                with QuantumTape() as tape3:
+                with QuantumTape():
                     qml.PauliZ(0)
 
         expected = (
@@ -463,49 +474,45 @@ class TestNestedTapes:
             "0: ──Z─┤  "
         )
 
-        assert tape_text(tape) == expected
+        assert tape_text(_tape) == expected
 
     def test_nested_tapes_decimals(self):
         """Test decimals keyword passed to nested tapes."""
 
-        with QuantumTape() as tape:
+        with QuantumTape() as _tape:
             qml.RX(1.2345, wires=0)
-            with QuantumTape() as tape0:
+            with QuantumTape():
                 qml.Rot(1.2345, 2.3456, 3.456, wires=0)
 
-        expected = "0: ──RX(1.2)──Tape:0─┤  \n" "\nTape:0\n" "0: ──Rot(1.2,2.3,3.5)─┤  "
+        expected = "0: ──RX(1.2)──Tape:0─┤  \n\nTape:0\n0: ──Rot(1.2,2.3,3.5)─┤  "
 
-        assert tape_text(tape, decimals=1) == expected
+        assert tape_text(_tape, decimals=1) == expected
 
     def test_nested_tapes_wire_order(self):
         """Test wire order preserved in nested tapes."""
 
-        with QuantumTape() as tape:
+        with QuantumTape() as _tape:
             qml.PauliX(0)
             qml.PauliY(1)
-            with QuantumTape() as tape0:
+            with QuantumTape():
                 qml.PauliX(0)
                 qml.PauliY(1)
 
-        expected = (
-            "1: ──Y─╭Tape:0─┤  \n" "0: ──X─╰Tape:0─┤  \n" "\nTape:0\n" "1: ──Y─┤  \n0: ──X─┤  "
-        )
+        expected = "1: ──Y─╭Tape:0─┤  \n0: ──X─╰Tape:0─┤  \n\nTape:0\n1: ──Y─┤  \n0: ──X─┤  "
 
-        assert tape_text(tape, wire_order=[1, 0]) == expected
+        assert tape_text(_tape, wire_order=[1, 0]) == expected
 
     def test_nested_tapes_max_length(self):
         """Test max length passes to recursive tapes."""
 
-        with QuantumTape() as tape:
+        with QuantumTape() as _tape:
             qml.PauliX(0)
-            with QuantumTape() as tape0:
+            with QuantumTape():
                 for _ in range(10):
                     qml.PauliX(0)
 
-        expected = (
-            "0: ──X──Tape:0─┤  \n" "\nTape:0\n" "0: ──X──X──X──X──X\n" "\n───X──X──X──X──X─┤  "
-        )
+        expected = "0: ──X──Tape:0─┤  \n\nTape:0\n0: ──X──X──X──X──X\n\n───X──X──X──X──X─┤  "
 
-        out = tape_text(tape, max_length=20)
+        out = tape_text(_tape, max_length=20)
         assert out == expected
         assert max(len(s) for s in out.split("\n")) <= 20