Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ParamSpec in make_qscript function signature #6726

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pennylane/tape/qscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from collections import Counter
from collections.abc import Callable, Hashable, Iterable, Iterator, Sequence
from functools import cached_property
from typing import Any, Optional, TypeVar, Union
from typing import Any, Optional, ParamSpec, TypeVar, Union

import pennylane as qml
from pennylane.measurements import MeasurementProcess, ProbabilityMP, StateMP
Expand Down Expand Up @@ -1376,10 +1376,12 @@ def map_to_standard_wires(self) -> "QuantumScript":
return fn(tapes)


# TODO: Use "ParamSpecs" when min Python version is 3.10
def make_qscript(
fn: Callable[..., Any], shots: Optional[ShotsLike] = None
) -> Callable[..., QuantumScript]:
# ParamSpec is used to preserve the exact signature of the input function `fn`
P = ParamSpec("P")
T = TypeVar("T")


def make_qscript(fn: Callable[P, T], shots: Optional[ShotsLike] = None) -> Callable[P, QS]:
"""Returns a function that generates a qscript from a quantum function without any
operation queuing taking place.

Expand Down
Loading