Skip to content

Commit

Permalink
Merge pull request #1377 from CEED/jeremy/rust-update
Browse files Browse the repository at this point in the history
Rust - clearer t501 error message
  • Loading branch information
jeremylt authored Oct 13, 2023
2 parents 48a3759 + 1ce8139 commit 0ef64b8
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions rust/libceed/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1191,17 +1191,18 @@ mod tests {
// Restrictions
let mut indx: Vec<i32> = vec![0; 2 * nelem];
for i in 0..nelem {
indx[2 * i + 0] = i as i32;
indx[2 * i + 1] = (i + 1) as i32;
for j in 0..2 {
indx[2 * i + j] = (i + j) as i32;
}
}
let rx = ceed.elem_restriction(nelem, 2, 1, 1, nelem + 1, MemType::Host, &indx)?;
let mut indu: Vec<i32> = vec![0; p * nelem];
for i in 0..nelem {
indu[p * i + 0] = i as i32;
indu[p * i + 1] = (i + 1) as i32;
indu[p * i + 2] = (i + 2) as i32;
for j in 0..p {
indu[p * i + j] = (i + j) as i32;
}
}
let ru = ceed.elem_restriction(nelem, 3, 1, 1, ndofs, MemType::Host, &indu)?;
let ru = ceed.elem_restriction(nelem, p, 1, 1, ndofs, MemType::Host, &indu)?;
let strides: [i32; 3] = [1, q as i32, q as i32];
let rq = ceed.strided_elem_restriction(nelem, q, 1, q * nelem, strides)?;

Expand Down Expand Up @@ -1231,9 +1232,12 @@ mod tests {

// Check
let sum: Scalar = v.view()?.iter().sum();
let error: Scalar = (sum - 2.0).abs();
assert!(
(sum - 2.0).abs() < 1e-15,
"Incorrect interval length computed"
error < 1e-15,
"Incorrect interval length computed. Expected: 2.0, Found: {}, Error: {:.12e}",
sum,
error
);
Ok(())
}
Expand Down

0 comments on commit 0ef64b8

Please sign in to comment.