Repository navigation
Fix Record.wrsamp() when d_signal is missing - #619
divya-git03 wants to merge 3 commits into
Conversation
|
Thanks for picking this up! I checked that physical-only records from One problem: record = wfdb.rdrecord("sample-data/100", sampto=1000)
record.wrsamp()
record.p_signal = record.p_signal * 2
record.wrsamp() # writes the original signal, not the doubled oneCould you convert only for the write and put converted = None
if not expanded and self.d_signal is None and self.p_signal is not None:
self.d_signal = self.adc()
converted = "d_signal"
elif expanded and self.e_d_signal is None and self.e_p_signal is not None:
self.e_d_signal = self.adc(expanded=True)
converted = "e_d_signal"
try:
... # the existing checksum update and writing
finally:
if converted:
setattr(self, converted, None)For the tests:
Could you also add "Fixes #618" to the description, and put the changelog entry on one line like the others? We're planning to merge #620, which moves changelog entries into separate files in |
As discussed in #606: each change now adds its own file in `changelog.d/` instead of editing `docs/changes.rst`, so pull requests no longer conflict on the changelog. - Fragments are plain `.rst` files named after the change (for example `rr2ann-fixes.rst`), in the same bold-heading format as now. `changelog.d/README.rst` explains this. - At release time, `uv run towncrier build --version X.Y.Z --date "Mon YYYY"` adds a `Version X.Y.Z (Mon YYYY)` section to `docs/changes.rst` and deletes the fragments. Entries are sorted by file name. - The 25 existing unreleased entries are moved into `changelog.d/` unchanged. I checked that `towncrier build --draft` reproduces them exactly, and ran a real build on a copy: the docs build passes with `-W` both before and after. - `towncrier` is pinned in the `dev` group, like Ruff. AGENTS.md and DEVELOPING.md are updated. One trade-off: the unreleased changes no longer show on the docs site until a release. If you'd like them there, `sphinxcontrib-towncrier` can render a draft section, but that touches `docs/conf.py`, so I'd do it after #616. #619 and #583 add entries to `docs/changes.rst`, so they'd need to move them into a fragment after this is merged (or the other way round, whichever goes in first).
|
Thanks for the detailed review! I've addressed the requested changes:
I've pushed the updates in commit I've also updated the PR description with Thanks again for the guidance! |
Fixes #618
Problem
Record.wrsamp() raises a TypeError when a record contains physical signal data (p_signal) but has no digital signal data (d_signal). This occurs because checksum calculation expects digital samples.
Changes
Convert p_signal to digital samples using the existing adc() method when d_signal is None.
Apply the conversion only when expanded=False and physical signal data is available.
Preserve the existing behavior for records that already contain digital signals.
Add a regression test using sample-data/100 to verify that a physical-only record can be written and read back with the expected digital samples.
Add an entry to the unreleased changelog.
Testing
python -m pytest -q tests/test_record.py
90 passed, 1 skipped.
The skipped test was network-dependent and encountered a remote connection error.
git diff --check completed successfully.
Fix writing physical-only and expanded physical signals without retaining converted digital samples on the record.