Skip to content

Commit

Permalink
Fix spacing in register.max_connectivity (#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-corni authored Nov 8, 2023
1 parent 7c2ddee commit 2bad427
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 6 additions & 5 deletions pulser-core/pulser/register/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,6 @@ def max_connectivity(
f" ({device.max_atom_num})."
)

if not device.min_atom_distance > 0.0:
raise NotImplementedError(
"Maximum connectivity layouts are not well defined for a "
f"device with 'min_atom_distance={device.min_atom_distance}'."
)
# Default spacing or check minimal distance
if spacing is None:
spacing = device.min_atom_distance
Expand All @@ -268,6 +263,12 @@ def max_connectivity(
" distance supported by this device"
f" ({device.min_atom_distance})."
)
if spacing <= 0.0:
# spacing is None or 0.0, device.min_atom_distance is 0.0
raise NotImplementedError(
"Maximum connectivity layouts are not well defined for a "
"device with 'min_atom_distance=0.0'."
)

coords = patterns.triangular_hex(n_qubits) * spacing

Expand Down
6 changes: 2 additions & 4 deletions tests/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,8 @@ def test_max_connectivity():
# Check spacing
reg = Register.max_connectivity(max_atom_num, device, spacing=spacing)
with pytest.raises(ValueError, match="Spacing "):
reg = Register.max_connectivity(
max_atom_num, device, spacing=spacing - 1.0
)

Register.max_connectivity(max_atom_num, device, spacing=spacing - 1.0)
reg = Register.max_connectivity(max_atom_num, MockDevice, spacing=spacing)
with pytest.raises(
NotImplementedError,
match="Maximum connectivity layouts are not well defined for a "
Expand Down

0 comments on commit 2bad427

Please sign in to comment.