pennylane
pennylane copied to clipboard
Add `StateMeasurement.process_density_matrix` method
Important Note
⚠️ This issue is part of an internal assignment and not meant for external contributors.
Context
Currently, measurements in PennyLane must define how to calculate the resulting number from "terminal" information, such as state, samples, or counts. For example, we have already implemented and required a StateMeasurement.process_state(state, wire_order)
method. See the module documentation on measurements for more detailed information here.
But this method is specific to statevector-based simulators. To expand this framework to density-matrix based simulators like default.mixed
, we need to add an additional method.
Implementation Details
This task is to add a new method to StateMeasurement
:
class StateMeasurement(MeasurementProcess):
def process_density_matrix(self, density_matrix, wire_order: Wires):
raise NotImplementedError
And implement it for ProbabilityMP
(bonus points for an implementation for StateMP
, DensityMatrixMP
)
Relevant functions include:
Additional Requirements
A completed PR would:
- Include a docstring for the new
StateMeasurement.process_density_matrix
method - Include a changelog entry at
doc/releases/changelog-dev.md
. Make sure to include your name in the list of contributors at the bottom! - Add tests to
tests/measurements/test_measurements.py
,tests/measurements/test_state.py
, andtests/measurements/test_probs.py
- Pass all existing tests including black and pylint checks