calc_adc_params can produce off-by-one problems, crashing wrsamp
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start with calc_adc_params as called by wfdb.wrsamp, using the attached data.float32 file and the reproduction snippet to trigger the failure. Inspect how chmin and chmax are derived for fmt 32 and compare them with the allowed range. Done means the reproduction completes without an IndexError while values remain within the format limits.
Written by the indexing model from the issue text.
Description
I have some data that crashes wrsamp because calc_adc_params produces values that don't fit the data (off by one):
chmin = -2147483648
chmax = 2147483648
IndexError: Channel 0 contain values outside allowed range [-2147483648, 2147483647] for fmt 32
As you can see, chmax is just above the dmax of 2147483647 for 32.
This is some data for reproduction:
data.float32.zip
You can try it with:
data = np.reshape(np.fromfile("data.float32", dtype=np.float32), [-1, 12])
wfdb.wrsamp(
record_name="test",
sig_name=[f"d{x}" for x in range(12)],
units=["mv"] * 12,
fs=500,
# fmt=["16"] * 12,
p_signal=data
)
Note how passing fmt=16 fixes the problem in this particular case, probably by chance because it happens to not trigger the bug.
- Dominant language
- Jupyter Notebook
- Stars
- 853
- Forks
- 322
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MIT-LCP/wfdb-python
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
MIT-LCP/wfdb-python#568 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
MIT-LCP/wfdb-python#557 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 58/100
MIT-LCP/wfdb-python#554 ·
-
WFDB path ignored Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
MIT-LCP/wfdb-python#545 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
MIT-LCP/wfdb-python#540 ·
All issues in MIT-LCP/wfdb-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
robjhyndman/forecast#1220 ·
-
Add: New Channel Openchannels:add check:passed
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
good first issue help wanted NLnet
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
collective/icalendar#1819 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
confluentinc/dbt-confluent#160 ·
-
inceleme-kuyrugu
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Greater-Turkiye/platform#107 ·