Skip to content

ClusterView (2.1.0rc1, release-2.1 Qt table): numpy-typed columns (id/sh/depth/amp) render blank #1377

Description

@stottbot

I could not view certain columns in Phy, with the latest pre-release. Certain columns were blank. This bug, was discovered by Claude Code. A one line edit fixed the issue and everything rendered correctly. Description below is by Claude Code.

Summary

In phy 2.1.0rc1 (installed via pip install phy --pre), several ClusterView columns render as empty cells: id, sh, depth, amp. Other columns in the same table (ch, fr, n_spikes, Amplitude) display normally. The underlying data is fine — values are present in cluster_info.tsv, and the Waveform/Trace views work — so it's purely a display bug in the new Qt-native table.

Cause

This is the new release-2.1 Qt table (_TableModel(QAbstractTableModel) in phy/gui/widgets.py). data() returns the raw value for DisplayRole without converting numpy scalars:

if role in (Qt.DisplayRole, Qt.EditRole):
    return '' if value is None else value

PyQt renders numpy scalars (np.int64/np.float64) as blank. The columns that disappear are exactly the numpy-typed ones — id (cluster_id), sh (model.channel_shanks[best]), depth, amp (np.mean(...)) — while the visible columns happen to be native Python (ch label, fr from a Python division, n_spikes count, Amplitude parsed from TSV).

Repro

  1. pip install phy --pre (lands on 2.1.0rc1, release-2.1 branch)
  2. phy template-gui params.py on any Kilosort/SpikeInterface output
  3. ClusterView: id, sh, depth, amp columns are blank.

Suggested fix

Convert numpy scalars to native Python in _TableModel.data():

if role in (Qt.DisplayRole, Qt.EditRole):
    if value is None:
        return ''
    if isinstance(value, np.generic):
        value = value.item()
    return value

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions