Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Release notes
.. toctree::
:maxdepth: 1

releases/0.4.2.rst
releases/0.4.1.rst
releases/0.4.0.rst
releases/0.3.2.rst
Expand Down
9 changes: 9 additions & 0 deletions doc/releases/0.4.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
probeinterface 0.4.2
--------------------

Oct, 16th 2026


Bug fixes
^^^^^^^^^
* Fix duplicate ``probe_id`` field in ``ProbeGroup.to_numpy(complete=True)`` (#473)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "probeinterface"
version = "0.4.1"
version = "0.4.2"
authors = [
{ name="Samuel Garcia", email="sam.garcia.die@gmail.com" },
{ name="Alessio Buccino", email="alessiop.buccino@gmail.com" },
Expand Down
4 changes: 3 additions & 1 deletion src/probeinterface/probegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,14 @@ def to_numpy(self, complete: bool = False) -> np.ndarray:

# loop over probes to get all fields
dtype = [("probe_index", "int64"), ("probe_id", "U100")]
# set by the probegroup: skip same-named contact annotations (e.g. from files saved with probeinterface<0.4)
group_fields = [name for name, _ in dtype]
fields = []
for probe_index, probe in enumerate(self.probes):
arr = probe.to_numpy(complete=complete)
probe_arr.append(arr)
for k in arr.dtype.fields:
if k not in fields:
if k not in fields and k not in group_fields:
fields.append(k)
dtype += [(k, arr.dtype.fields[k][0])]

Expand Down
16 changes: 16 additions & 0 deletions tests/test_probegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ def test_probegroup_3d():
assert probegroup.ndim == 3


def test_to_numpy_with_probe_id_contact_annotation():
"""A 'probe_id' contact annotation (e.g. from files saved with probeinterface<0.4) must not
duplicate the probegroup 'probe_id' field."""
probegroup = ProbeGroup()
for i in range(2):
probe = generate_dummy_probe()
probe.move([i * 100, 0])
probe.annotate_contacts(probe_id=["0"] * probe.get_contact_count())
probegroup.add_probe(probe)

arr = probegroup.to_numpy(complete=True)
assert list(arr.dtype.names).count("probe_id") == 1
assert np.array_equal(np.unique(arr["probe_id"]), ["0", "1"])
ProbeGroup.from_numpy(arr)


def test_probegroup_allows_duplicate_positions_across_probes():
"""Test that ProbeGroup allows duplicate contact positions if they are in different probes."""
from probeinterface import ProbeGroup, Probe
Expand Down
Loading