Skip to content

Commit

Permalink
Improved error message and fixing pylint error
Browse files Browse the repository at this point in the history
  • Loading branch information
PietropaoloFrisoni committed Jun 3, 2024
1 parent f3ef0ec commit a1d2ef0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions pennylane/devices/default_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class DefaultTensor(Device):
wires (int, Iterable[Number, str]): Number of wires present on the device, or iterable that
contains unique labels for the wires as numbers (i.e., ``[-1, 0, 2]``) or strings
(``['aux_wire', 'q1', 'q2']``).
method (str): Supported method. Currently, only ``"mps"`` is supported.
method (str): Supported method. Currently, the supported methods are 'mps' (Matrix Product State) and 'tns' (Exact Tensor Network).
dtype (type): Data type for the tensor representation. Must be one of ``np.complex64`` or ``np.complex128``.
**kwargs: keyword arguments for the device, passed to the ``quimb`` backend.
Expand All @@ -172,7 +172,8 @@ class DefaultTensor(Device):
contract (str): The contraction method for applying gates in the MPS method. It can be either ``auto-mps`` or ``nonlocal``.
``nonlocal`` turns each gate into a Matrix Product Operator (MPO) and applies it directly to the MPS,
while ``auto-mps`` swaps nonlocal qubits in 2-qubit gates to be next to each other before applying the gate,
then swaps them back. Default is ``auto-mps``.
then swaps them back. Default is ``auto-mps``. TODO: change this
# TODO: add options for TNS
**Example:**
Expand Down Expand Up @@ -536,7 +537,9 @@ def _get_measurement_function(
if isinstance(measurementprocess, VarianceMP):
return self.var

raise NotImplementedError
raise NotImplementedError(
f"Measurement process {measurementprocess} currently not supported by default.tensor."
)

def expval(self, measurementprocess: MeasurementProcess) -> float:
"""Expectation value of the supplied observable contained in the MeasurementProcess.
Expand Down
2 changes: 1 addition & 1 deletion tests/devices/default_tensor/test_default_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def test_not_implemented_meas(self, method):
measurements = [qml.probs(qml.PauliZ(0))]
tape = qml.tape.QuantumScript(op, measurements)

dev = qml.device("default.tensor", wires=tape.wires)
dev = qml.device("default.tensor", wires=tape.wires, method=method)

with pytest.raises(NotImplementedError):
dev.execute(tape)
Expand Down

0 comments on commit a1d2ef0

Please sign in to comment.