Skip to content

Fix numpy array conversion for LindiH5pyDataset#121

Merged
magland merged 4 commits into
mainfrom
fix-numpy-array-conversion
Mar 9, 2026
Merged

Fix numpy array conversion for LindiH5pyDataset#121
magland merged 4 commits into
mainfrom
fix-numpy-array-conversion

Conversation

@bendichter

Copy link
Copy Markdown
Contributor

Summary

  • Override __array__ and _is_empty on LindiH5pyDataset to prevent h5py's inherited methods from calling self.id.get_space(), which fails because id is a string in lindi's implementation
  • Adds regression test for numpy array conversion (np.asarray, np.atleast_2d)

Fixes #120

Test plan

🤖 Generated with Claude Code

Override __array__ and _is_empty on LindiH5pyDataset to prevent h5py's
inherited methods from calling self.id.get_space(), which fails because
id is a string in lindi's implementation.

Fixes #120

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Mar 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.63%. Comparing base (6a196a7) to head (4254c1a).

Files with missing lines Patch % Lines
lindi/LindiH5pyFile/LindiH5pyDataset.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #121      +/-   ##
==========================================
+ Coverage   81.39%   81.63%   +0.23%     
==========================================
  Files          30       30              
  Lines        2784     2793       +9     
==========================================
+ Hits         2266     2280      +14     
+ Misses        518      513       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bendichter bendichter requested review from magland and rly March 8, 2026 21:28
Comment thread lindi/LindiH5pyFile/LindiH5pyDataset.py Outdated
@rly

rly commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

@bendichter Can you also update this to support datasets with a compound dtype?

edit: I believe self[:] will fail in those cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bendichter

Copy link
Copy Markdown
Contributor Author

Addressed review feedback - added copy=False check consistent with h5py and simplified dtype handling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@magland magland merged commit c13ab73 into main Mar 9, 2026
6 checks passed
@magland magland deleted the fix-numpy-array-conversion branch March 9, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_space error when using pynapple

4 participants