Skip to content

Commit

Permalink
More 0.32 related fixes (#4520)
Browse files Browse the repository at this point in the history
* Remove function use that causes hash warning

* Remove MeasurementValueError

* Sphinx fix

* Changed to list comprehension
  • Loading branch information
mudit2812 authored Aug 25, 2023
1 parent 9d23fe3 commit aa4172f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion doc/code/qml_measurements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ qml.measurements
:no-heading:
:include-all-objects:
:inheritance-diagram:
:skip: MeasurementShapeError, MeasurementValueError, ObservableReturnTypes
:skip: MeasurementShapeError, ObservableReturnTypes
2 changes: 1 addition & 1 deletion pennylane/measurements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def circuit(x):
Variance,
VnEntropy,
)
from .mid_measure import MeasurementValue, MeasurementValueError, MidMeasureMP, measure
from .mid_measure import MeasurementValue, MidMeasureMP, measure
from .mutual_info import MutualInfoMP, mutual_info
from .purity import PurityMP, purity
from .probs import ProbabilityMP, probs
Expand Down
4 changes: 0 additions & 4 deletions pennylane/measurements/mid_measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ def hash(self):
return hash(fingerprint)


class MeasurementValueError(ValueError):
"""Error raised when an unknown measurement value is being used."""


class MeasurementValue(Generic[T]):
"""A class representing unknown measurement outcomes in the qubit model.
Expand Down
10 changes: 5 additions & 5 deletions pennylane/optimize/adaptive.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ def step_and_cost(self, circuit, operator_pool, drain_pool=False, params_zero=Tr
qnode = copy.copy(circuit)

if drain_pool:
repeated_gates = [
operator_pool = [
gate
for gate in operator_pool
for operation in circuit.tape.operations
if (gate.name == operation.name and gate.wires == operation.wires)
if all(
gate.name != operation.name or gate.wires != operation.wires
for operation in circuit.tape.operations
)
]
for gate in repeated_gates:
operator_pool.remove(gate)

params = np.array([gate.parameters[0] for gate in operator_pool], requires_grad=True)
qnode.func = self._circuit
Expand Down

0 comments on commit aa4172f

Please sign in to comment.