Skip to content

Copy-edit the integration tests for simplicity #281

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 1 commit into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1133,8 +1133,10 @@ impl<T: Element> PyArray<T, Ix2> {
/// ```
pub fn from_vec2<'py>(py: Python<'py>, v: &[Vec<T>]) -> Result<&'py Self, FromVecError> {
let last_len = v.last().map_or(0, |v| v.len());
if v.iter().any(|v| v.len() != last_len) {
return Err(FromVecError::new(v.len(), last_len));
for v in v {
if v.len() != last_len {
return Err(FromVecError::new(v.len(), last_len));
}
}
let dims = [v.len(), last_len];
unsafe {
Expand Down Expand Up @@ -1171,12 +1173,18 @@ impl<T: Element> PyArray<T, Ix3> {
/// ```
pub fn from_vec3<'py>(py: Python<'py>, v: &[Vec<Vec<T>>]) -> Result<&'py Self, FromVecError> {
let len2 = v.last().map_or(0, |v| v.len());
if v.iter().any(|v| v.len() != len2) {
return Err(FromVecError::new(v.len(), len2));
for v in v {
if v.len() != len2 {
return Err(FromVecError::new(v.len(), len2));
Comment on lines +1176 to +1178
Copy link
Member

Choose a reason for hiding this comment

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

Oops, this is a nice catch, thank you.

}
}
let len3 = v.last().map_or(0, |v| v.last().map_or(0, |v| v.len()));
if v.iter().any(|v| v.iter().any(|v| v.len() != len3)) {
return Err(FromVecError::new(v.len(), len3));
for v in v {
for v in v {
if v.len() != len3 {
return Err(FromVecError::new(v.len(), len3));
}
}
}
let dims = [v.len(), len2, len3];
unsafe {
Expand Down
Loading