diff --git a/src/probeinterface/probe.py b/src/probeinterface/probe.py index c19ddd6..d260a17 100644 --- a/src/probeinterface/probe.py +++ b/src/probeinterface/probe.py @@ -527,7 +527,7 @@ def set_device_channel_indices(self, channel_indices: np.ndarray | list): """ channel_indices = np.asarray(channel_indices, dtype=int) if channel_indices.size != self.get_contact_count(): - ValueError( + raise ValueError( f"channel_indices {channel_indices.size} do not have " f"the same size as contacts {self.get_contact_count()}" ) diff --git a/tests/test_probe.py b/tests/test_probe.py index 631b6d3..e1cd5f8 100644 --- a/tests/test_probe.py +++ b/tests/test_probe.py @@ -141,6 +141,19 @@ def test_probe(): # ~ plt.show() +def test_set_device_channel_indices_rejects_wrong_size(): + """Setting device_channel_indices with wrong count raises ValueError.""" + probe = Probe(ndim=2, si_units="um") + probe.set_contacts( + positions=np.array([[0, 0], [10, 0], [20, 0]]), + shapes="circle", + shape_params={"radius": 5}, + ) + + with pytest.raises(ValueError, match="do not have"): + probe.set_device_channel_indices([0, 1]) + + def test_probe_equality_dunder(): probe1 = generate_dummy_probe() probe2 = generate_dummy_probe()