Skip to content

Report offending input in register error messages - #1095

Open
jaewonyun1234 wants to merge 1 commit into
pasqal-io:developfrom
jaewonyun1234:error-messages-register
Open

Report offending input in register error messages#1095
jaewonyun1234 wants to merge 1 commit into
pasqal-io:developfrom
jaewonyun1234:error-messages-register

Conversation

@jaewonyun1234

Copy link
Copy Markdown
Contributor

Same as #1094, applied to base_register.py.

Nine messages updated: __init__, _init_kwargs, find_indices,
from_coordinates, four in _validate_layout, and define_detuning_map.

Also fixed a missing space that printed as Label length (3) does notmatch number of coordinates (2).

I left "Cannot create a Register with an empty qubit dictionary." alone. The
dictionary is empty, so there's nothing to print.

One thing I noticed: trap_coords[trap_id] on line 229 isn't bounds checked, so
a bad trap id gives a numpy error instead of a Pulser one.

>>> Register(qubits, layout=layout, trap_ids=(0, 99))
IndexError: index 99 is out of bounds for axis 0 with size 4

RegisterLayout.define_register catches this but the Register constructor
skips that check. I didn't fix it here since it changes behaviour, not wording.

Partially addresses #1057.

Adds the failing input to the 9 validation errors in base_register.py that previously stated only the rule, following the pattern from pasqal-io#1094. Existing message text is kept intact and details appended, so all match= assertions in tests/ continue to pass without modification. Also fixes a missing space in the label-length message, which rendered as 'does notmatch'. Partially addresses pasqal-io#1057.
@jaewonyun1234

Copy link
Copy Markdown
Contributor Author

Hi @a-corni ready for review whenever you have time.

For the trap_ids bounds check I mentioned at the bottom — happy to fold a fix
into this PR, or open it as a separate issue. Whichever you prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant