diff --git a/pyquil/api/_qam.py b/pyquil/api/_qam.py index 9effee992..21bc34945 100644 --- a/pyquil/api/_qam.py +++ b/pyquil/api/_qam.py @@ -53,11 +53,13 @@ class QAMExecutionResult: def raw_readout_data(self) -> Union[QVMResultData, QPUResultData]: """ Get the raw result data. This will either be a ``QVMResultData`` or ``QPUResultData`` - depending on where you ran the job. + depending on where the job was run. - This property is best used when running programs that use advanced features like - mid-circuit measurement and dynamic control flow on a QPU since they can produce - irregular result shapes that don't necessarily fit in a rectangular matrix. + This property should be used when running programs that use features like + mid-circuit measurement and dynamic control flow on a QPU, since they can + produce irregular result shapes that don't necessarily fit in a + rectangular matrix. If the program was run on a QVM, or doesn't use those + features, consdier using the ``register_map`` property instead. """ return self.data.result_data.inner() @@ -80,11 +82,11 @@ def register_map(self) -> Mapping[str, Optional[np.ndarray]]: register_map = self.data.result_data.to_register_map() return {key: matrix.to_ndarray() for key, matrix in register_map.items()} + @property @deprecated( version="4.0.0", reason="This property is ambiguous now that the `raw_readout_data` property exists and will be removed in future versions. Use `register_map` property instead", ) - @property def readout_data(self) -> Mapping[str, Optional[np.ndarray]]: """Readout data returned from the QAM, keyed on the name of the readout register or post-processing node.""" return self.register_map diff --git a/pyquil/api/_qvm.py b/pyquil/api/_qvm.py index 6a2fb96e5..84b6fe7e2 100644 --- a/pyquil/api/_qvm.py +++ b/pyquil/api/_qvm.py @@ -53,8 +53,10 @@ class QVMExecuteResponse: executable: Program data: QVMResultData - def mapping(self) -> Mapping[str, np.ndarray]: - return {key: value.as_ndarray() for key, value in self.data.memory.items()} + @property + def memory(self): + register_map = self.data.to_register_map() + return {key: matrix.to_ndarray() for key, matrix in register_map.items()} class QVM(QAM[QVMExecuteResponse]): @@ -153,11 +155,7 @@ def execute( options=QVMOptions(timeout_seconds=self.timeout), ) - # result_data = ResultData(result) - # data = ExecutionData(result_data=result_data, duration=None) - - # memory = {name: np.asarray(data.inner()) for name, data in result.memory.items()} - return QVMExecuteResponse(executable=executable, data=result) # memory=memory) + return QVMExecuteResponse(executable=executable, data=result) def get_result(self, execute_response: QVMExecuteResponse) -> QAMExecutionResult: """