Skip to content

Support converting Array1<usize> #98

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
Jun 13, 2019
Merged

Support converting Array1<usize> #98

merged 2 commits into from
Jun 13, 2019

Conversation

rth
Copy link
Contributor

@rth rth commented Jun 13, 2019

On master, trying to convert e.g. an Array1<usize> to Python fails due to the conversion not being implemented for usize dtype.

I tried to add it following the suggestion in rust-ndarray/ndarray#493 (comment)

If I understand correctly, usize should map to either np.uint32 or np.uint64 depending on the architecture.

src/types.rs Outdated
cfg_if! {
if #[cfg(all(target_pointer_width = "64", windows))] {
impl_type_num!(usize, Uint64, NPY_ULONGLONG);
} else if #[cfg(all(target_pointer_width = "64", not (windows)))] {
Copy link
Member

Choose a reason for hiding this comment

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

I think we this(not (windows) space is redundunt

src/types.rs Outdated
impl_type_num!(usize, Uint64, NPY_ULONG, NPY_ULONGLONG);
} else if #[cfg(all(target_pointer_width = "32", windows))] {
impl_type_num!(usize, Uint32, NPY_UINT, NPY_ULONG);
} else if #[cfg(all(target_pointer_width = "32", not (windows)))] {
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

@kngwyu
Copy link
Member

kngwyu commented Jun 13, 2019

Thanks for your PR!
LGTM except for a minor formatting problem.

@rth
Copy link
Contributor Author

rth commented Jun 13, 2019

Thanks for the review @kngwyu ! Formatting should be fixed now.

@kngwyu kngwyu merged commit b54bb16 into PyO3:master Jun 13, 2019
@kngwyu
Copy link
Member

kngwyu commented Jun 13, 2019

Thanks, again

@rth rth deleted the intp-support branch June 13, 2019 15:09
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

Successfully merging this pull request may close these issues.

2 participants