Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Better error messages for references to undefined memory locations #1304

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pyquil/api/_qpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])})")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is len(patch[k.name]) supposed to be len(patch_values[k.name])?

On that note, it could be worth adding a simple test case. Even with 3.x in the works, 2.x will be in use for a long tail

patch_values[k.name][k.index] = v

return patch_values
Expand Down