Skip to content

BUG: <TypeError: Indexing arrays must have integer dtypes when reading H5 files with h5py >= 3.0' prefix> #1220

@alex-attinger

Description

@alex-attinger

Describe the issue:

Running suite2p on an H5 input file raises the following error:

File "suite2p/io/h5.py", line 88, in h5py_to_binary
    im = f[key][irange, ...]
TypeError: Indexing arrays must have integer dtypes

In h5py_to_binary, the index array irange is computed using float division:

irange = np.arange(
    ik / ncp, min(ik / ncp + nbatch / ncp, nframes_all / ncp),
    1)

np.arange returns a float64 array. h5py >= 3.0 no longer silently casts float indices to integers and raises a TypeError instead. This was a deliberate breaking change introduced in h5py 3.0.
Suggested fix
Use floor division (//) and explicit dtype=int to keep the index array in integer space:

Reproduce the code example:

python -m suite2p --settings --verbose
creating log file 
2026-03-16 15:54:43,993 [INFO] 
platform:       	win32 
python version: 	3.11.15

Example input dataset used to reproduce the issue:

No response

Error message:

Version information:

v1.0.0.1

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions