Skip to content

Commit 3aa0f76

Browse files
committed
Fix display of multi-valued cluster metadata
1 parent 09c8d1d commit 3aa0f76

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

docs/changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This file records user-visible changes to phy. The format is based on
88

99
Changes below are available from the latest source checkout but have not yet
1010
been included in a stable release. The current entries cover all user-visible
11-
changes committed on 23–24 July 2026; test-only commits are represented by the
11+
changes committed since 23 July 2026; test-only commits are represented by the
1212
behavior they verify rather than listed separately.
1313

1414
### Added
@@ -48,6 +48,8 @@ behavior they verify rather than listed separately.
4848
- Cluster and Similarity View filters only take keyboard focus after an
4949
explicit click, including when a table is first shown or refreshed. Enter,
5050
Escape, and outside clicks release filter focus so global shortcuts resume.
51+
- Display metadata columns containing multiple values in the Cluster and
52+
Similarity Views instead of leaving their cells blank.
5153

5254
### Changed
5355

phy/cluster/tests/test_supervisor.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,18 @@ def test_cluster_view_formats_spike_counts(qtbot, gui):
242242
assert index.data(Qt.EditRole) == 1234567
243243

244244

245+
def test_cluster_view_formats_multiple_values(qtbot, gui):
246+
cv = ClusterView(
247+
gui,
248+
data=[{'id': 1, 'n_spikes': 10, 'tags': ['tag_a', 'tag_b']}],
249+
columns=['tags'],
250+
)
251+
_wait_until_table_ready(qtbot, cv)
252+
253+
index = cv._proxy.index(0, cv.columns.index('tags'))
254+
assert index.data(Qt.DisplayRole) == 'tag_a, tag_b'
255+
256+
245257
def test_similarity_view_1(qtbot, gui):
246258
sv = SimilarityView(gui)
247259
_wait_until_table_ready(qtbot, sv)

phy/gui/widgets.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from contextlib import contextmanager
1515
from functools import partial
1616

17+
import numpy as np
1718
from phylib.utils import connect, emit
1819
from phylib.utils._misc import _CustomEncoder, _pretty_floats
1920
from phylib.utils._types import _is_integer
@@ -364,8 +365,13 @@ def data(self, index, role=Qt.DisplayRole):
364365
return ''
365366
# Qt's model/view cannot display numpy scalars (np.int64/np.float64),
366367
# which render as blank cells; convert them to native Python types.
367-
if hasattr(value, 'item'):
368+
if isinstance(value, np.generic):
368369
value = value.item()
370+
if role == Qt.DisplayRole:
371+
if isinstance(value, np.ndarray):
372+
value = value.tolist()
373+
if isinstance(value, (list, tuple)):
374+
return ', '.join(map(str, value))
369375
# Keep the raw value available for sorting and filtering, while making
370376
# spike counts easier to scan in the cluster and similarity tables.
371377
if role == Qt.DisplayRole and column == 'n_spikes' and isinstance(value, int):

0 commit comments

Comments
 (0)