Repository navigation
Commit f59c445
authored
Read format 61 signals with smooth_frames=False (#678)
`rdrecord` with `physical=False` and `smooth_frames=False` fails for any
record with a format 61 signal:
```python
wfdb.rdrecord("sample-data/p10143", physical=False, smooth_frames=False)
# ValueError: invalid literal for int() with base 10: ''
```
`convert_dtype` compared dtypes by parsing their names
(`int(str(dtype)[3:])`). Format 61 is stored in big-endian byte order,
so its dtype is `>i2`, which has nothing after the first three
characters. It now uses `np.can_cast(current_dtype, return_dtype,
"safe")`, which handles byte order. Samples are returned in the
requested native dtype, and asking for a dtype that is too small still
raises the same "lower dtype" error.
This is the read that a lossless round trip needs (#484, #500). It
affects `p10143` and `binformats` in `sample-data`. Writing format 61 is
still not supported, so those two records can be read this way but not
yet written back.
Testing:
- New `TestExpandedBigEndian` checks the samples and dtype for
`return_res` of 16, 32 and 64, that a dtype that is too small is
rejected, and a record mixing format 61 with other formats. All of them
fail on `main`.
- `uv run pytest -m "not network" -W error` (571 passed), the network
tests in `tests/test_record.py` (14 passed), `ruff format --check` and
`ruff check` pass. Changelog entry added in `changelog.d/`.
Refs #484, #500
<sub>@tompollard 🟥 red 🐳 whale · quince</sub>3 files changed
Lines changed: 51 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
940 | 940 | | |
941 | 941 | | |
942 | 942 | | |
943 | | - | |
| 943 | + | |
944 | 944 | | |
945 | 945 | | |
946 | 946 | | |
| |||
951 | 951 | | |
952 | 952 | | |
953 | 953 | | |
954 | | - | |
| 954 | + | |
955 | 955 | | |
956 | 956 | | |
957 | 957 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1949 | 1949 | | |
1950 | 1950 | | |
1951 | 1951 | | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
1952 | 1999 | | |
1953 | 2000 | | |
1954 | 2001 | | |
| |||
0 commit comments