Computing template metrics on an analyzer saved before 0.104.0 raises KeyError

オープン
#5,009 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
data

調査の方向性

Start by reading ComputeTemplateMetrics._handle_backward_compatibility_on_load and BaseMetricExtension._run, then trace how saved metric names and table columns are restored. Check the compatibility behavior for peak_to_valley, half_width, and peak_trough_ratio, including whether computed metrics are updated and users are warned when values need recomputing. Done means loading metrics saved by 0.103 and computing template metrics no longer raises a KeyError.

索引モデルが issue の本文から書いたものです。

説明

I came across this while looking at what happens to saved metric tables when a metric's columns change.

If an analyzer has template metrics saved by 0.103, computing any template metric on it with version >= 0.104.0 raises a KeyError.

The reason is that #4306 renamed or reworked some template metrics. On load, _handle_backward_compatibility_on_load updates the saved metric names, but not the saved metric table columns. When one then goes to compute more metrics, BaseMetricExtension._run copies the previously computed metrics into the new table column by column, using the columns each metric has now (not the saved ones that escaped renaming).

For example, 0.103 had a metric and column named peak_to_valley. The metric name is now mapped to peak_to_trough_duration, and this is the name used to look up the column on copy, but of course it isn't found. So it raises KeyError: 'peak_to_trough_duration'.

Other examples I found:

  • half_width: The metric name is still half_width, but the expected columns are trough_half_width and peak_half_width.
  • peak_trough_ratio: The metric name is now waveform_ratios and the expected columns are peak_before_to_trough_ratio, peak_after_to_trough_ratio, peak_before_to_peak_after_ratio, main_peak_to_trough_ratio.

Here is what I would do, in ComputeTemplateMetrics._handle_backward_compatibility_on_load:

  • Since peak_to_valley seems to have only changed its name and its old values equal the new peak_to_trough_duration, rename its saved column to peak_to_trough_duration, matching the existing renaming of the metric.
  • Since half_width and peak_trough_ratio changed what they compute, their old values can't simply be relabeled, so drop their columns from the saved table, remove half_width and waveform_ratios from the computed metrics, and warn that they need recomputing.

I can open a PR for this.

主要言語
Python
スター
883
フォーク
291
平均マージ
3日 17時間
マージ済み PR(30日)
40

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

SpikeInterface/spikeinterface のほかの issue

SpikeInterface/spikeinterface の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。