Repository: PennyLaneAI/pennylane
Pull request #3478 (2022-12-06 17:28:12)

deprecate make_tape
**Context:**
It's not used anywhere in the codebase anymore, and we don't want any new code to use it

**Description of the Change:**
Add a deprecation warning when `make_tape` is used.

**Benefits:**
People will know to use `make_qscript` instead.

**Possible Drawbacks:**
N/A

github-actions[bot]: Hello. You may have forgotten to update the changelog!
Please edit [`doc/releases/changelog-dev.md`](/PennyLaneAI/pennylane/blob/master/doc/releases/changelog-dev.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/3478?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) Report
> Merging [#3478](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3478?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) (b5fe563) into [master](https://codecov.io/gh/PennyLaneAI/pennylane/commit/e9394eadd3d9dc1dcb6ef6057965eb0ce139fcca?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) (e9394ea) will **increase** coverage by `0.01%`.
> The diff coverage is `100.00%`.

```diff
@@            Coverage Diff             @@
##           master    #3478      +/-   ##
==========================================
+ Coverage   99.69%   99.71%   +0.01%     
==========================================
  Files         308      308              
  Lines       27166    27167       +1     
==========================================
+ Hits        27084    27090       +6     
+ Misses         82       77       -5     
```


| [Impacted Files](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3478?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) | Coverage Δ | |
|---|---|---|
| [pennylane/transforms/qfunc\_transforms.py](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3478/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI#diff-cGVubnlsYW5lL3RyYW5zZm9ybXMvcWZ1bmNfdHJhbnNmb3Jtcy5weQ==) | `100.00% <100.00%> (+6.94%)` | :arrow_up: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI)


Patch:
diff --git a/doc/development/deprecations.rst b/doc/development/deprecations.rst
index 134089962..4c427538f 100644
--- a/doc/development/deprecations.rst
+++ b/doc/development/deprecations.rst
@@ -100,6 +100,12 @@ Pending deprecations
 
     tapes, fn = qml.transforms.hamiltonian_expand(tape)
 
+* ``qml.transforms.make_tape`` has been deprecated, and usage will now raise a warning.
+  Instead, use ``qml.tape.make_qscript``.
+
+  - Deprecated in v0.28
+  - Will be removed in v0.29
+
 Completed deprecation cycles
 ----------------------------
 
diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md
index b5a63207d..befcbfa12 100644
--- a/doc/releases/changelog-dev.md
+++ b/doc/releases/changelog-dev.md
@@ -511,6 +511,9 @@ Deprecations cycles are tracked at [doc/developement/deprecations.rst](https://d
   wanted seed.
   [(#3388)](https://github.com/PennyLaneAI/pennylane/pull/3388)
 
+* `make_tape` is deprecated. Please use `qml.tape.make_qscript` instead.
+  [(#3478)](https://github.com/PennyLaneAI/pennylane/pull/3478)
+
 <h3>Documentation</h3>
 
 * Adds developer documentation for the queuing module.
diff --git a/pennylane/transforms/qfunc_transforms.py b/pennylane/transforms/qfunc_transforms.py
index ba42e6fc7..45e2ca911 100644
--- a/pennylane/transforms/qfunc_transforms.py
+++ b/pennylane/transforms/qfunc_transforms.py
@@ -65,6 +65,8 @@ def make_tape(fn):
     [RY(1.0, wires=[0])]
     """
 
+    warnings.warn("``make_tape`` is deprecated in favor of ``qml.tape.make_qscript``", UserWarning)
+
     def wrapper(*args, **kwargs):
         with qml.QueuingManager.stop_recording(), qml.tape.QuantumTape() as new_tape:
             fn(*args, **kwargs)


Test patch:
diff --git a/tests/transforms/test_qfunc_transform.py b/tests/transforms/test_qfunc_transform.py
index 424bf8691..aae5a3f88 100644
--- a/tests/transforms/test_qfunc_transform.py
+++ b/tests/transforms/test_qfunc_transform.py
@@ -323,6 +323,15 @@ class TestQFuncTransforms:
 
         assert original_fn is decorated_transform
 
+    def test_make_tape_is_deprecated(self):
+        """Test that make_tape is deprecated and points users to make_qscript."""
+
+        def circuit(x):
+            qml.RX(x, wires=0)
+
+        with pytest.warns(UserWarning, match="qml.tape.make_qscript"):
+            tape = qml.transforms.make_tape(circuit)(0.1)
+
 
 ############################################
 # Test transform, ansatz, and qfunc function