10000 DOC: add examples to ctypeslib by m-clare · Pull Request #27598 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DOC: add examples to ctypeslib #27598

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

Merged
merged 2 commits into from
Oct 19, 2024
Merged

Conversation

m-clare
Copy link
Contributor
@m-clare m-clare commented Oct 19, 2024

@m-clare m-clare marked this pull request as draft October 19, 2024 16:45
add examples to ctyleslib: as_ctypes, as_array
@m-clare m-clare force-pushed the ctypeslib-examples branch from 2a297f3 to c83ee2e Compare October 19, 2024 16:49
@m-clare m-clare marked this pull request as ready for review October 19, 2024 16:50
@ngoldbaum
Copy link
Member

>>> exp_int_array = np.array([1, 2, 3], dtype=np.uint8)
>>> c_int_array = np.ctypeslib.as_ctypes(exp_int_array)
>>> c_int_array
<c_ubyte_Array_3 at 0x10755a950>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine to merge as-is, but this repr isn't really helpful. Maybe print something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a type check and printing the array contents itself.

Add additional method test on ctype conversion
@ngoldbaum
Copy link
Member

Thanks @m-clare!

@ngoldbaum ngoldbaum merged commit e9fca94 into numpy:main Oct 19, 2024
4 checks passed
@m-clare m-clare deleted the ctypeslib-examples branch October 20, 2024 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: Examples in docstrings – tracking issue
2 participants
0