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

Contiguous checking #105

Merged
merged 4 commits into from
Jul 4, 2019
Merged

Contiguous checking #105

merged 4 commits into from
Jul 4, 2019

Conversation

kngwyu
Copy link
Member

@kngwyu kngwyu commented Jul 3, 2019

Resolves #101.
Add methods to check the array is contiguous or not and use these methods in as_slice and as_slice_mut.

- To resolve PyO3#101, we check if the array is contiguous when getting a slice
src/array.rs Outdated
| self.check_flag(npyffi::NPY_ARRAY_F_CONTIGUOUS)
}

pub fn is_forran_contiguous(&self) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: fortran

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, thank you for pointing out.

unsafe { (*self.as_array_ptr()).flags & flag == flag }
}

pub fn is_contiguous(&self) -> bool {
Copy link
Contributor

@rth rth Jul 3, 2019

Choose a reason for hiding this comment

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

Maybe worth adding a docstring indicating that this returns true if the array is either C or Fortran contiguous

@kngwyu
Copy link
Member Author

kngwyu commented Jul 4, 2019

I'm going to add a method to get a contiguous array in the next PR.

@kngwyu kngwyu merged commit 83761e6 into PyO3:master Jul 4, 2019
@kngwyu kngwyu deleted the contiguous branch July 4, 2019 03:40
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.

'as_slice()' successfully reports incorrect data on noncontiguous arrays
2 participants