From 5716e4cfa582e1a140cdcfa1983006d45da62448 Mon Sep 17 00:00:00 2001 From: Mark Skilbeck Date: Mon, 8 Mar 2021 15:05:26 +0000 Subject: [PATCH] Fix: Better error messages for references to undefined memory locations --- pyquil/api/_qpu.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyquil/api/_qpu.py b/pyquil/api/_qpu.py index 1fdf90b58..b6b12f8be 100644 --- a/pyquil/api/_qpu.py +++ b/pyquil/api/_qpu.py @@ -310,6 +310,10 @@ def _build_patch_values(self) -> Dict[str, List[Union[int, float]]]: # Fill in our patch table for k, v in self._variables_shim.items(): + if k.name not in patch_values: + raise KeyError(f"{k.name} is not one of the valid memory descriptors: {patch_values.keys()}") + if k.index >= len(patch_values[k.name]): + raise IndexError(f"{k.name} has more parameter values ({k.index}) than expected ({len(patch[k.name])})") patch_values[k.name][k.index] = v return patch_values