Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation fore "return type" of nidigital fetch_capture_waveform method is unclear #2081

Open
gfisher-NI opened this issue Feb 17, 2025 · 4 comments

Comments

@gfisher-NI
Copy link
Contributor

In the documentation for the fetch_capture_waveform method of nidigital, "Return type" is listed as "{ int: memoryview of array.array of unsigned int, int: memoryview of array.array of unsigned int, … }".

Image

This is extremely confusing and gives almost no indication of how to interpret the return type, other than it being a key-value pair.

@gfisher-NI
Copy link
Contributor Author

As far as I can tell, the only way to convert the return type into something usable is to index it and then convert it to bytes:

capture_samples = digital_session.fetch_capture_waveform('capture_waveform',1)
print(bytes(capture_samples[0]))

@bkeryan
Copy link
Contributor

bkeryan commented Feb 17, 2025

The text above says

Returns dictionary where each key is a site number and value is a collection of digital states representing capture waveform data

I think that means the return type should be something like dict[int, memoryview[int]] or dict[int, collections.abc.Buffer[int]]. I assume the fact that the memoryview references an array is a hidden implementation detail.

Related: Moving the type documentation out of the docstring and into a type hint would enable validating it at build time. #1887

@gfisher-NI
Copy link
Contributor Author

@bkeryan The fact that it's an array is one thing that isn't clear, but also, if I just index into the array I get something that looks like:

<memory at 0x000001B8F00A5700>

So there needs to be something about needing to perform some sort of conversion or interpretation.

@bkeryan
Copy link
Contributor

bkeryan commented Feb 17, 2025

@gfisher-NI Are you indexing a single element or a slice? It seems that slicing a memoryview returns another memoryview that refers to the sliced data: https://docs.python.org/3/library/stdtypes.html#memoryview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants