Skip to content

fix: small robustness fixes in sync, fnirs and xdf - #316

Merged
Ramdam17 merged 5 commits into
masterfrom
fix/small-fixes-fnirs-xdf-sync
Oct 4, 2026
Merged

Ramdam17 merged 5 commits into
masterfrom
fix/small-fixes-fnirs-xdf-sync

Conversation

@Ramdam17

@Ramdam17 Ramdam17 commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

What this does

Six small defects found by the October audit. Each replaces a crash or a wrong message; no call that worked before returns a different value.

hypyp/sync

  • import hypyp.analyses failed when the import of torch, numba, cupy or the Metal bindings raised anything other than ImportError, for example the OSError of a missing shared library. The four probes now tell an absent package, skipped silently as before, from an installed one that fails to load, which disables the backend with a warning giving the original error. An installed package that failed with an ImportError was skipped silently and now gets that warning too. A package that imports but is broken further down is not covered.
  • get_metric rejected envelope_corr, pow_corr and imaginary_coh, which compute_sync accepts. The mapping is hypyp.sync.METRIC_ALIASES; a name registered in METRICS takes precedence over an alias.
  • The warnings for a missing numba or torch suggested poetry install --with optim_*, which no longer exists; they give the pip extras.

hypyp/fnirs

  • Recording.load_raw raised TypeError on a Raw without subject_info (any RawArray) and KeyError when his_id was absent; the random label that the next lines intended is now reached.
  • Study.compute_wtcs_shuffle raised TypeError when given with_intra=False, since it passes that argument itself. The redundant False is accepted, so the keyword arguments of compute_wtcs can be reused. with_intra=True is still refused.

hypyp/xdf

  • XDFImport(select_matches=[id]) raised a bare KeyError for an unknown integer id and treated a numpy integer as a stream name. An unknown id raises the same ValueError as an unknown name, and a numpy integer is an id.

Measured

  • 31 new tests, written first. Twenty of them import hypyp in a fresh interpreter with a fake optional package that fails in four different ways, or is reported absent.
  • Whole suite on macOS arm64, Python 3.12, with torch, numba and PyObjC Metal installed, after merging master (which now holds fix: clear errors instead of crashes in analyses, stats and utils #315): 388 passed, 12 skipped, 0 failed.
  • CUDA on the Tamia cluster (H100), same merge commit (44a666d): 391 passed, 9 skipped, 0 failed, and the backend each of the nine metrics resolves to, for eight kinds of request, is identical to what master gave before this pull request.

Withdrawn after review

Study() uses a mutable default, so two studies created without arguments share one list of dyads. Giving each its own list changes what the second study computes, so the repair is kept for 0.7.0.

Left out on purpose

compute_sync keeps its own copy of the alias table in this pull request, to avoid a conflict with #315, which edits the same lines. The new tests of test_fnirs.py and test_xdf.py live in modules that download sample data when collected, like the tests around them.

🤖 Generated with Claude Code

Ramdam17 and others added 3 commits October 4, 2026 09:25
An optional package that is installed but fails to import (torch, numba,
cupy, Metal) no longer makes hypyp fail to import: the backend is disabled
with a warning that gives the original error. get_metric accepts
envelope_corr, pow_corr and imaginary_coh as compute_sync does. The hints
for a missing numba or torch give the pip extras instead of a poetry
command that no longer exists.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Study() no longer shares its default list of dyads between objects.
Recording.load_raw gives the intended random label to a Raw without
subject_info or without his_id. Study.compute_wtcs_shuffle accepts
with_intra. XDFImport raises ValueError for an unknown stream id and
recognises a numpy integer as a stream id.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

Ramdam17 and others added 2 commits October 4, 2026 10:08
Study() keeps its shared default list for now: giving each study its own
list changes what a second Study() computes, so it belongs to 0.7.0.
compute_wtcs_shuffle accepts only the redundant with_intra=False and still
refuses True. get_metric looks a name up in METRICS before trying the
aliases, so a metric registered under an alias name is still returned.
The probes of the optional packages tell an absent package, skipped
silently, from an installed one that fails to load, which now warns
whatever the exception, ImportError included.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Ramdam17
Ramdam17 merged commit 6fd1eaa into master Oct 4, 2026
10 checks passed
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