Skip to content

Commit 6c94c35

Browse files
authored
error (#430)
1 parent 192dc86 commit 6c94c35

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/probeinterface/probe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ def set_device_channel_indices(self, channel_indices: np.ndarray | list):
527527
"""
528528
channel_indices = np.asarray(channel_indices, dtype=int)
529529
if channel_indices.size != self.get_contact_count():
530-
ValueError(
530+
raise ValueError(
531531
f"channel_indices {channel_indices.size} do not have "
532532
f"the same size as contacts {self.get_contact_count()}"
533533
)

tests/test_probe.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,19 @@ def test_probe():
141141
# ~ plt.show()
142142

143143

144+
def test_set_device_channel_indices_rejects_wrong_size():
145+
"""Setting device_channel_indices with wrong count raises ValueError."""
146+
probe = Probe(ndim=2, si_units="um")
147+
probe.set_contacts(
148+
positions=np.array([[0, 0], [10, 0], [20, 0]]),
149+
shapes="circle",
150+
shape_params={"radius": 5},
151+
)
152+
153+
with pytest.raises(ValueError, match="do not have"):
154+
probe.set_device_channel_indices([0, 1])
155+
156+
144157
def test_probe_equality_dunder():
145158
probe1 = generate_dummy_probe()
146159
probe2 = generate_dummy_probe()

0 commit comments

Comments
 (0)