LibraryInterpreter.read_raw and write_raw do not allow switching array dtypes
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 592
- Forks
- 199
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 10
Description
LibraryInterpreter.read_raw sets cfunc.argtypes based on the dtype of the array you pass in:
def read_raw(self, task, num_samps_per_chan, timeout, read_array):
samples_read = ctypes.c_int()
number_of_bytes_per_sample = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxReadRaw
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.c_int, ctypes.c_double,
wrapped_ndpointer(dtype=read_array.dtype, flags=('C', 'W')),
ctypes.c_uint, ctypes.POINTER(ctypes.c_int),
ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)]
...
However, this is incorrect because cfunc.argtypes is only initialized once.
I haven't tested this yet, but I expect it to remember the dtype of the 1st array that you pass to task.in_stream.read_into() and reject any array with a different dtype.
I think the correct way to make ndpointer accept any array dtype is to specify dtype=None.
Contributor guide
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.
Research direction
Start with LibraryInterpreter.read_raw and write_raw, then follow the task.in_stream.read_into entry point. Check how cfunc.argtypes and wrapped_ndpointer use the first array's dtype, and verify that read and write operations accept arrays with different dtypes without rejection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100