Task.read interprets data incorrectly for short reads
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- api, testing-qa
Hướng nghiên cứu
Bắt đầu với nidaqmx.Task.read và bài kiểm thử được mô tả trong tests/component/test_task_read_ai.py, đặc biệt là trường hợp thu thập hữu hạn nhiều kênh với lần đọc thiếu mẫu. Tái hiện lỗi bằng cách đặt samples_to_acquire thành 5 và samples_to_read thành 10, sau đó xác minh rằng dữ liệu 2D được trả về chứa các mẫu hợp lệ cho từng kênh mà không có giá trị nào bị ghi đè.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When DAQmxReadAnalogF64 with DAQmx_Val_GroupByChannel returns fewer samples than requested, it squashes the valid samples together at the beginning of the buffer. The way that nidaqmx.Task.read handles short reads doesn't take this into account, so it may return samples that have been overwritten.
Test case (from tests/component/test_task_read_ai.py, under development):
def test___analog_multi_channel_finite___read_too_many_sample___returns_valid_2d_channels_samples_truncated(
ai_multi_channel_task: nidaqmx.Task,
) -> None:
samples_to_acquire = 5
ai_multi_channel_task.timing.cfg_samp_clk_timing(rate=1000.0, sample_mode=AcquisitionType.FINITE, samps_per_chan=samples_to_acquire)
num_channels = ai_multi_channel_task.number_of_channels
samples_to_read = 10
data = ai_multi_channel_task.read(samples_to_read)
expected = [
[_get_voltage_offset_for_chan(chan_index) for _ in range(samples_to_acquire)]
for chan_index in range(num_channels)
]
_assert_equal_2d(data, expected, abs=VOLTAGE_EPSILON)
Result (lib and grpc fail the same way, because the underlying interpreters have consistent behavior here):
_ test___analog_multi_channel_finite___read_too_many_sample___returns_valid_2d_channels_samples_truncated[library_init_kwargs] _
ai_multi_channel_task = Task(name=_unnamedTask<0>)
def test___analog_multi_channel_finite___read_too_many_sample___returns_valid_2d_channels_samples_truncated(
ai_multi_channel_task: nidaqmx.Task,
) -> None:
samples_to_acquire = 5
ai_multi_channel_task.timing.cfg_samp_clk_timing(rate=1000.0, sample_mode=AcquisitionType.FINITE, samps_per_chan=samples_to_acquire)
num_channels = ai_multi_channel_task.number_of_channels
samples_to_read = 10
data = ai_multi_channel_task.read(samples_to_read)
expected = [
[_get_voltage_offset_for_chan(chan_index) for _ in range(samples_to_acquire)]
for chan_index in range(num_channels)
]
> _assert_equal_2d(data, expected, abs=VOLTAGE_EPSILON)
tests\component\test_task_read_ai.py:144:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
data = [[1.000091555528428, 1.000396740623188, 1.000396740623188, 0.999786370433668, 0.999786370433668], [3.000274666585284, ...4, 2.999969481490524], [3.000274666585284, 3.000579851680044, 3.000579851680044, 2.999969481490524, 2.999969481490524]]
expected = [[1.0, 1.0, 1.0, 1.0, 1.0], [2.0, 2.0, 2.0, 2.0, 2.0], [3.0, 3.0, 3.0, 3.0, 3.0]], abs = 0.001
def _assert_equal_2d(data: List[List[float]], expected: List[List[float]], abs: float) -> None:
# pytest.approx() does not support nested data structures.
assert len(data) == len(expected)
for i in range(len(data)):
> assert data[i] == pytest.approx(expected[i], abs=abs)
E assert [3.000274666585284, 3.000579851680044, 3.000579851680044, 2.999969481490524, 2.999969481490524] == approx([2.0 ± 1.0e-03, 2.0 ± 1.0e-03, 2.0 ± 1.0e-03, 2.0 ± 1.0e-03, 2.0 ± 1.0e-03])
E
E comparison failed. Mismatched elements: 5 / 5:
E Max absolute difference: 1.000579851680044
E Max relative difference: 0.3334621643612693
E Index | Obtained | Expected
E 0 | 3.000274666585284 | 2.0 ± 1.0e-03
E 1 | 3.000579851680044 | 2.0 ± 1.0e-03
E 2 | 3.000579851680044 | 2.0 ± 1.0e-03
E 3 | 2.999969481490524 | 2.0 ± 1.0e-03
E 4 | 2.999969481490524 | 2.0 ± 1.0e-03
tests\component\test_task_read_ai.py:151: AssertionError
NI IO Trace shows:
The original array was
[1,1,1,1,1,0,0,0,0,0,2,2,2,2,2,0,0,0,0,0,3,3,3,3,3,0,0,0,0,0]
then it was squashed to
[1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x]
When this happened, the old 2s were overwritten with 3s.
This test case passes if you increase the number of samples to acquire because a larger read buffer prevents the old/new sample positions from overlapping.
- Ngôn ngữ chính
- Python
- Star
- 590
- Fork
- 199
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ni/nidaqmx-python
-
Add PEP 723 dependency metadata to example programsCó thể đã có người làm @shrishsk đã nhận 2 ngày trước. Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
ni/nidaqmx-python#1030 ·
-
tech debt
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
ni/nidaqmx-python#945 ·
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
ni/nidaqmx-python#941 ·
-
Potential typos in the APICó thể đã có người làm @KostaIlic2 đã nhận 214 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
ni/nidaqmx-python#939 ·
-
Add gRPC examplesĐang mởenhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
ni/nidaqmx-python#917 · 1 bình luận · 1 reaction ·
Tất cả issue của ni/nidaqmx-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
SwiftKickMobile/skai#84 ·
-
Lychee link check failedĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jxxghp/MoviePilot#7070 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
flop-labs/technocore-chat#997 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
tunneld on Windows: Wi-Fi devices are not discovered because uvicorn runs on a ProactorEventLoopĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
doronz88/pymobiledevice3#2051 ·
Maintainer thường phản hồi trong vòng 1 ngày