Skip to content

Release 0.6.2

Latest

Choose a tag to compare

@Ramdam17 Ramdam17 released this 04 Oct 17:40

Fixed

  • hypyp.sync: asking for the Metal backend on a metric that has no Metal kernel (PLV, CCorr, Coh, ImCoh, EnvCorr, PowCorr) used to run in NumPy silently, while the metric object reported metal. The computation still runs in NumPy, so no computed value changes, but it now warns and the metric object reports numpy. This holds for optimization='metal' and for a priority list that reaches Metal on a machine where Metal is available: the backends that follow in the list are not tried, which is left to 0.7.0. Only PLI, wPLI and ACCorr have a Metal kernel; the default selection of optimization='auto' is unchanged for the nine built-in metrics (#299)
  • hypyp.sync: when a backend of a priority list can neither run on the machine nor be computed by the metric, and no other GPU backend of the list can be used, the warning now says so (for example "'plv' has no Metal implementation") instead of "No GPU backend available"
  • hypyp.sync: a metric whose _backend was set to a backend it does not implement used to compute in NumPy without notice. It still computes in NumPy, now with a warning. A _backend that is not the name of a backend raises a ValueError naming the metric and the backends it implements (#306)
  • Tests: the six Metal tests that compared NumPy with NumPy are replaced by tests of the fallback itself (warning, backend and result), the dispatch of every metric to every backend it implements is checked without a GPU, and the four tests that run a Metal kernel now assert that the Metal method was called (#300)
  • 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 backend is now reported as unavailable, with a warning that gives the original error. An installed package that fails with an ImportError used to be skipped silently and now gets the same warning; a package that is not installed is still skipped silently. A package that imports but is broken further down is not covered
  • hypyp.sync.get_metric rejected the names envelope_corr, pow_corr and imaginary_coh, which compute_sync accepts and the documentation uses. It now accepts them; the mapping is hypyp.sync.METRIC_ALIASES, and a metric registered in METRICS under one of these names takes precedence
  • hypyp.sync: the warnings for a missing numba or torch suggested a poetry install command that no longer exists; they now give pip install "hypyp[numba]" and pip install "hypyp[torch]"
  • hypyp.fnirs.Recording.load_raw raised a TypeError for a Raw object without subject_info, as built in memory with mne.io.RawArray, and a KeyError when subject_info had no his_id. Both now get the random label that was intended
  • hypyp.fnirs.Study.compute_wtcs_shuffle raised a TypeError when given with_intra=False, so the keyword arguments of compute_wtcs could not be reused. That redundant argument is now accepted; with_intra=True is still refused
  • XDFImport(select_matches=[...]): an integer that is not the id of a stream raised a bare KeyError; it now raises the same ValueError as an unknown stream name. A numpy integer is recognised as a stream id
  • compute_sync and pair_connectivity reported every ValueError as Metric type "..." not supported, so an unknown optimization was announced as an unsupported metric. Only an unknown metric name gets that message now; any other error keeps its own (#306)
  • pair_connectivity crashed with an IndexError when the frequencies were given as a list and the data had a single epoch, a single channel per participant or a single frequency. Results for data without such a dimension are unchanged
  • utils.normalizing raised an UnboundLocalError for a type name other than 'Zscore' or 'Logratio'; it now raises a ValueError naming the two valid types
  • utils.generate_virtual_epoch failed inside the solver for an odd number of channels; it now raises a ValueError saying that the number must be even, and its docstring example uses four oscillators
  • utils.epochs_from_tasks failed with min() iterable argument is empty when the onset event of a task was absent from the recording; the ValueError now names the task and the event
  • utils.create_epochs warns when the two participants give different numbers of epochs, or, when both are given as lists, different numbers of recordings. It still returns what it returned before
  • stats.statscluster raised an UnboundLocalError for an unknown test; it now raises a ValueError listing the valid names

Added

  • stats.metaconn_matrix has a plot argument. It defaults to True, the earlier behaviour; plot=False computes the matrices without drawing
  • BaseMetric.supports(backend) tells whether a metric implements a backend, for example PLI.supports('metal')

Changed

  • hypyp.sync: backend dispatch now lives in BaseMetric.compute, and each built-in metric implements _compute_numpy plus the optional _compute_numba, _compute_torch, _compute_metal and _compute_cuda. This is the recommended way to write a new metric: set _dispatch_via_table = True in the class. A subclass written the earlier way, which overrides compute and does its own dispatch, is still granted the backend it requests and is not subject to the capability check, whether it derives from BaseMetric or from a built-in metric. A subclass of a built-in metric that overrides compute and delegates to super().compute() keeps the earlier results: a backend without a _compute_* method computes in NumPy, now with a warning, and the CPU fallback of optimization='auto' still selects numba for it when numba is installed. A _compute_* method that a subclass adds for a backend its parent does not implement was never called before and is still not, unless the subclass sets _dispatch_via_table = True itself; a method of the parent that the subclass overrides is used, as before
  • The whole code base is formatted with ruff format (line length 88). The change is purely cosmetic: the syntax tree of every file is unchanged, apart from whitespace inside docstrings, and the Python examples of hypyp/sync/README.md are formatted too. The vendored hypyp/ext and the tutorial notebooks are left untouched. The formatting commit is listed in .git-blame-ignore-revs, so git blame skips it (run git config blame.ignoreRevsFile .git-blame-ignore-revs once in your clone; GitHub applies it automatically)
  • The CI now checks formatting (ruff format --check) and a small set of lint rules that only catch certain bugs: syntax errors, invalid comparisons and undefined names. Ruff comes from the new lint dependency group, which the dev group includes
  • black is removed from the dev dependency group, since ruff format replaces it