qrisp.QuantumArray.get_measurement#
- QuantumArray.get_measurement(backend=None, shots=None, compile=True, compilation_kwargs={}, subs_dic={}, circuit_preprocessor=None, precompiled_qc=None)[source]#
Method for acquiring measurement results for the given array. The semantics are similar to the
get_measurement
method of QuantumVariable. The results are returned as a dictionary of another numpy subtype called OutcomeArray.- Parameters:
- backendBackendClient, optional
The backend on which to evaluate the quantum circuit. The default can be specified in the file default_backend.py.
- shotsinteger, optional
The amount of shots to evaluate the circuit. The default is given by the backend used.
- compilebool, optional
Boolean indicating if the .compile method of the underlying QuantumSession should be called before. The default is True.
- compilation_kwargsdict, optional
Keyword arguments for the compile method. For more details check
QuantumSession.compile
. The default is{}
.- subs_dicdict, optional
A dictionary of sympy symbols and floats to specify parameters in the case of a circuit with unspecified, abstract parameters. The default is {}.
- circuit_preprocessorPython function, optional
A function which recieves a QuantumCircuit and returns one, which is applied after compilation and parameter substitution. The default is None.
- Returns:
- list of tuples
The measurement results in the form [(outcome_label, probability), …].
- Raises:
- Exception
Tried to get measurement within open environment.
Examples
>>> from qrisp import QuantumFloat, QuantumArray >>> qtype = QuantumFloat(3) >>> q_array = QuantumArray(qtype) >>> q_array[:] = [[1,0],[0,1]] >>> res = q_array.get_measurement() >>> print(res) {OutcomeArray([[1, 0], [0, 1]]): 1.0}