prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Avoid quadratic scaling of template integration tests
  #### Issue description
  
  Currently, in ``test_templates.py`` a compatibility test is performed by having every template in the library (of the same device) applied before every other one - a quadratic growth of test cases in the number of templates. This becomes prohibitive, and we should find another solution that tests templates' compatibility.
  
  #### Additional information
  
  The issue could be easily fixed by defining small dummy templates that are called before and after the tested template. We could also try to make the tested templates pass parameters to each other.
  
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pennylane/templates/embeddings/basis.py`
  Content:
  ```
  1 # Copyright 2018-2020 Xanadu Quantum Technologies Inc.
  2 
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 r"""
  15 Contains the ``BasisEmbedding`` template.
  16 """
  17 # pylint: disable-msg=too-many-branches,too-many-arguments,protected-access
  18 import numpy as np
  19 
  20 from pennylane.templates.decorator import template
  21 from pennylane.ops import BasisState
  22 from pennylane.templates.utils import check_shape, check_wires, get_shape
  23 
  24 
  25 @template
  26 def BasisEmbedding(features, wires):
  27     r"""Encodes :math:`n` binary features into a basis state of :math:`n` qubits.
  28 
  29     For example, for ``features=np.array([0, 1, 0])``, the quantum system will be
  30     prepared in state :math:`|010 \rangle`.
  31 
  32     .. warning::
  33 
  34         ``BasisEmbedding`` calls a circuit whose architecture depends on the binary features.
  35         The ``features`` argument is therefore not differentiable when using the template, and
  36         gradients with respect to the argument cannot be computed by PennyLane.
  37 
  38     Args:
  39         features (array): binary input array of shape ``(n, )``
  40         wires (Sequence[int] or int): qubit indices that the template acts on
  41 
  42     Raises:
  43         ValueError: if inputs do not have the correct format
  44     """
  45 
  46     #############
  47     # Input checks
  48 
  49     wires = check_wires(wires)
  50 
  51     expected_shape = (len(wires),)
  52     check_shape(
  53         features,
  54         expected_shape,
  55         msg="'features' must be of shape {}; got {}" "".format(expected_shape, get_shape(features)),
  56     )
  57 
  58     if any([b not in [0, 1] for b in features]):
  59         raise ValueError("'basis_state' must only consist of 0s and 1s; got {}".format(features))
  60 
  61     ###############
  62 
  63     features = np.array(features)
  64     BasisState(features, wires=wires)
  65
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/pennylane/templates/embeddings/basis.py b/pennylane/templates/embeddings/basis.py
  --- a/pennylane/templates/embeddings/basis.py
  +++ b/pennylane/templates/embeddings/basis.py
  @@ -15,11 +15,11 @@
   Contains the ``BasisEmbedding`` template.
   """
   # pylint: disable-msg=too-many-branches,too-many-arguments,protected-access
  -import numpy as np
  +from collections import Iterable
   
   from pennylane.templates.decorator import template
  -from pennylane.ops import BasisState
  -from pennylane.templates.utils import check_shape, check_wires, get_shape
  +from pennylane.templates.utils import check_shape, check_wires, get_shape, check_type
  +import pennylane as qml
   
   
   @template
  @@ -48,6 +48,10 @@
   
       wires = check_wires(wires)
   
  +    check_type(
  +        features, [Iterable], msg="'features' must be iterable; got type {}".format(type(features))
  +    )
  +
       expected_shape = (len(wires),)
       check_shape(
           features,
  @@ -60,5 +64,6 @@
   
       ###############
   
  -    features = np.array(features)
  -    BasisState(features, wires=wires)
  +    for wire, bit in zip(wires, features):
  +        if bit == 1:
  +            qml.PauliX(wire)
  
verification_info: {"golden_diff": "diff --git a/pennylane/templates/embeddings/basis.py b/pennylane/templates/embeddings/basis.py\n--- a/pennylane/templates/embeddings/basis.py\n+++ b/pennylane/templates/embeddings/basis.py\n@@ -15,11 +15,11 @@\n Contains the ``BasisEmbedding`` template.\n \"\"\"\n # pylint: disable-msg=too-many-branches,too-many-arguments,protected-access\n-import numpy as np\n+from collections import Iterable\n \n from pennylane.templates.decorator import template\n-from pennylane.ops import BasisState\n-from pennylane.templates.utils import check_shape, check_wires, get_shape\n+from pennylane.templates.utils import check_shape, check_wires, get_shape, check_type\n+import pennylane as qml\n \n \n @template\n@@ -48,6 +48,10 @@\n \n     wires = check_wires(wires)\n \n+    check_type(\n+        features, [Iterable], msg=\"'features' must be iterable; got type {}\".format(type(features))\n+    )\n+\n     expected_shape = (len(wires),)\n     check_shape(\n         features,\n@@ -60,5 +64,6 @@\n \n     ###############\n \n-    features = np.array(features)\n-    BasisState(features, wires=wires)\n+    for wire, bit in zip(wires, features):\n+        if bit == 1:\n+            qml.PauliX(wire)\n", "issue": "Avoid quadratic scaling of template integration tests\n#### Issue description\r\n\r\nCurrently, in ``test_templates.py`` a compatibility test is performed by having every template in the library (of the same device) applied before every other one - a quadratic growth of test cases in the number of templates. This becomes prohibitive, and we should find another solution that tests templates' compatibility.\r\n\r\n#### Additional information\r\n\r\nThe issue could be easily fixed by defining small dummy templates that are called before and after the tested template. We could also try to make the tested templates pass parameters to each other.\r\n\r\n\r\n\n", "before_files": [{"content": "# Copyright 2018-2020 Xanadu Quantum Technologies Inc.\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n#     http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nr\"\"\"\nContains the ``BasisEmbedding`` template.\n\"\"\"\n# pylint: disable-msg=too-many-branches,too-many-arguments,protected-access\nimport numpy as np\n\nfrom pennylane.templates.decorator import template\nfrom pennylane.ops import BasisState\nfrom pennylane.templates.utils import check_shape, check_wires, get_shape\n\n\n@template\ndef BasisEmbedding(features, wires):\n    r\"\"\"Encodes :math:`n` binary features into a basis state of :math:`n` qubits.\n\n    For example, for ``features=np.array([0, 1, 0])``, the quantum system will be\n    prepared in state :math:`|010 \\rangle`.\n\n    .. warning::\n\n        ``BasisEmbedding`` calls a circuit whose architecture depends on the binary features.\n        The ``features`` argument is therefore not differentiable when using the template, and\n        gradients with respect to the argument cannot be computed by PennyLane.\n\n    Args:\n        features (array): binary input array of shape ``(n, )``\n        wires (Sequence[int] or int): qubit indices that the template acts on\n\n    Raises:\n        ValueError: if inputs do not have the correct format\n    \"\"\"\n\n    #############\n    # Input checks\n\n    wires = check_wires(wires)\n\n    expected_shape = (len(wires),)\n    check_shape(\n        features,\n        expected_shape,\n        msg=\"'features' must be of shape {}; got {}\" \"\".format(expected_shape, get_shape(features)),\n    )\n\n    if any([b not in [0, 1] for b in features]):\n        raise ValueError(\"'basis_state' must only consist of 0s and 1s; got {}\".format(features))\n\n    ###############\n\n    features = np.array(features)\n    BasisState(features, wires=wires)\n", "path": "pennylane/templates/embeddings/basis.py"}], "after_files": [{"content": "# Copyright 2018-2020 Xanadu Quantum Technologies Inc.\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n#     http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nr\"\"\"\nContains the ``BasisEmbedding`` template.\n\"\"\"\n# pylint: disable-msg=too-many-branches,too-many-arguments,protected-access\nfrom collections import Iterable\n\nfrom pennylane.templates.decorator import template\nfrom pennylane.templates.utils import check_shape, check_wires, get_shape, check_type\nimport pennylane as qml\n\n\n@template\ndef BasisEmbedding(features, wires):\n    r\"\"\"Encodes :math:`n` binary features into a basis state of :math:`n` qubits.\n\n    For example, for ``features=np.array([0, 1, 0])``, the quantum system will be\n    prepared in state :math:`|010 \\rangle`.\n\n    .. warning::\n\n        ``BasisEmbedding`` calls a circuit whose architecture depends on the binary features.\n        The ``features`` argument is therefore not differentiable when using the template, and\n        gradients with respect to the argument cannot be computed by PennyLane.\n\n    Args:\n        features (array): binary input array of shape ``(n, )``\n        wires (Sequence[int] or int): qubit indices that the template acts on\n\n    Raises:\n        ValueError: if inputs do not have the correct format\n    \"\"\"\n\n    #############\n    # Input checks\n\n    wires = check_wires(wires)\n\n    check_type(\n        features, [Iterable], msg=\"'features' must be iterable; got type {}\".format(type(features))\n    )\n\n    expected_shape = (len(wires),)\n    check_shape(\n        features,\n        expected_shape,\n        msg=\"'features' must be of shape {}; got {}\" \"\".format(expected_shape, get_shape(features)),\n    )\n\n    if any([b not in [0, 1] for b in features]):\n        raise ValueError(\"'basis_state' must only consist of 0s and 1s; got {}\".format(features))\n\n    ###############\n\n    for wire, bit in zip(wires, features):\n        if bit == 1:\n            qml.PauliX(wire)\n", "path": "pennylane/templates/embeddings/basis.py"}]}