Skip to content

Faster load_svmfiles, empty files, tabs, nnz overflow guard (0.5.3) - #12

Merged
yoch merged 2 commits into
masterfrom
fix/loader-robustness
Oct 20, 2026
Merged

yoch merged 2 commits into
masterfrom
fix/loader-robustness

Conversation

@yoch

@yoch yoch commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Loader fixes for a 0.5.3 release.

  • Faster load_svmfiles. The number of columns came from Python's builtin max() over every index, which took 2.7 s on rcv1_test.multiclass (518,571 rows, 33.5M values). It now uses ndarray.max(). Best of 3 runs, uncompressed file, warm cache, Python 3.13:

    0.5.2 this PR
    load_svmfiles 9.72 s 7.30 s
    load_svmfile 7.68 s 7.50 s
  • Empty files. An empty file, or one with labels but no values, failed with unable to infer matrix dimensions (load_svmfile) or max() iterable argument is empty (load_svmfiles). It now loads as a matrix with 0 columns. load_svmfiles handles an empty file mixed with non-empty ones.

  • Tabs. Tabs count as whitespace around : and at the end of a line. A trailing tab used to raise invalid index.

  • Overflow guard. More than INT_MAX values in one file raises ValueError instead of silently wrapping the C int indptr. This is not covered by a test, since triggering it needs a file of more than 2³¹ values.

  • load_svmfile closes the file when parsing fails.

Version bumped to 0.5.3. Four new tests: 23 in total.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP

yoch and others added 2 commits October 20, 2026 08:45
- load_svmfiles computed the number of columns with Python's builtin max()
  over every index: 2.7 s on rcv1_test (33M values), now ndarray.max().
  load_svmfiles goes from 9.7 s to 7.3 s on that file.
- An empty file, or one with labels but no values, failed to load
  ('unable to infer matrix dimensions', 'max() iterable argument is empty');
  it now gives a matrix with 0 columns.
- Tabs count as whitespace around separators and at the end of lines; a
  trailing tab was read as an index.
- More than INT_MAX values raises ValueError instead of silently wrapping the
  C int indptr.
- load_svmfile closes the file when parsing fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP
@yoch
yoch merged commit 8d9f4b9 into master Oct 20, 2026
9 checks passed
@yoch
yoch deleted the fix/loader-robustness branch October 20, 2026 06:11
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.

1 participant