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

Fix contig check for single element arrays #1362

Merged
merged 2 commits into from
Feb 26, 2024
Merged

Conversation

bluss
Copy link
Member

@bluss bluss commented Feb 26, 2024

When an array has 0 or 1 elements, strides don't matter anymore. The general case of this function handled this correctly, but the special case for ndim == 1 did not.

Fixes #1359

src/split_at.rs Outdated Show resolved Hide resolved
@bluss bluss force-pushed the contig-for-single-element branch 2 times, most recently from 9f4cee3 to c033453 Compare February 26, 2024 19:46
bluss and others added 2 commits February 26, 2024 20:48
Co-authored-by: Adam Reichold <adamreichold@users.noreply.github.com>
When an array has 0 or 1 elements, strides don't matter anymore. The
general case of this function handled this correctly, but the special
case for ndim == 1 did not.

let arr2 = array![[1, 2, 3], [4, 5, 6]];
assert_matches!(arr2.slice(s![.., 2..3]).as_slice_memory_order(), None);
assert_matches!(arr2.slice(s![1, 2..3]).as_slice_memory_order(), Some(&[6]));
Copy link
Member Author

Choose a reason for hiding this comment

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

The 2D case was working correctly before this fix too.

@bluss
Copy link
Member Author

bluss commented Feb 26, 2024

thanks for checking. The lint fixes are helpful here too, best to get them in.

@bluss bluss merged commit 97ecc0d into master Feb 26, 2024
7 checks passed
@bluss bluss deleted the contig-for-single-element branch February 26, 2024 20:31
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.

ArrayBase::as_slice_memory_order returns None when slice has a single element
2 participants