Record.wrsamp() fails with a TypeError when the record has no d_signal

已關閉 適合新手
#618 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@divya-git03 已經在處理了。

開始於 2026年11月1日。

  • #619 來自 @divya-git03 —— 已合併

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
70/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
numpy, python
領域
data

研究方向

定位 Record 類(可能在 wfdb/record.py 中)並檢查 wrsamp() 和 calc_checksum()。執行提供的程式碼片段以重現 TypeError。決定是將 p_signal 轉換為 d_signal 還是拋出明確的錯誤;完成意味著寫入記錄成功或帶有有用訊息失敗。

由索引模型根據 Issue 內容生成。

描述

Record.wrsamp() fails with an unhelpful error for a record read with the default physical=True:

import wfdb

record = wfdb.rdrecord("sample-data/100", sampto=1000)
record.wrsamp(write_dir="out")
# TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'

The record only has p_signal, so d_signal is None. Record.wrsamp() first updates the checksums with calc_checksum(), which computes np.sum(self.d_signal, 0) % 65536 and fails on None. Reading with physical=False, or calling record.d_signal = record.adc() first, works.

#543 ran into the same error. Two possible fixes:

  1. Convert p_signal to d_signal with the record's adc_gain and baseline when d_signal is missing, so that a record read with rdrecord can be written back directly (which would also help with #500).
  2. At least raise a clear error saying that d_signal is required, and how to get it.
主要語言
Jupyter Notebook
星號
856
分支
326
平均合併
1 天 1 小時
30 天內合併 PR
43

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

MIT-LCP/wfdb-python 的其他 Issue

查看 MIT-LCP/wfdb-python 的全部 Issue

相似的 Issue

更多 Data Engineering Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。