|
| 1 | +test_that("ijkpos, c_sub2ind, c_coords21dindex", { |
| 2 | + origin <- c(10, 20, 30) |
| 3 | + voxdims <- c(1, 2, 3) |
| 4 | + dims <- c(20, 30, 40) |
| 5 | + |
| 6 | + xyz_mat <- matrix(c(10, 20, 30, |
| 7 | + 11, 22, 33, |
| 8 | + 40, 80, 160), ncol = 3, byrow = TRUE) |
| 9 | + xyz_df <- data.frame(x = c(10, 11), |
| 10 | + y = c(20, 22), |
| 11 | + z = c(30, 33)) |
| 12 | + bl=structure(c(1L, 2L, 20L, 1L, 2L, 30L, 1L, 2L, 40L), dim = c(3L, 3L)) |
| 13 | + |
| 14 | + expect_warning(expect_equal( |
| 15 | + c_ijkpos(xyz_mat, origin, voxdims, dims, clamp = TRUE), |
| 16 | + bl)) |
| 17 | + |
| 18 | + expect_silent(ijk <- c_ijkpos(xyz_mat[1:2,], origin, voxdims, dims, clamp = TRUE)) |
| 19 | + expect_equal(c_ijkpos(xyz_mat[1:2,], origin, voxdims, dims, clamp = TRUE), |
| 20 | + c_ijkpos(xyz_df, origin, voxdims, dims, clamp = TRUE)) |
| 21 | + |
| 22 | + bl=c(1,622) |
| 23 | + expect_equal(c_sub2ind(dims, indices = ijk),bl) |
| 24 | + expect_equal( |
| 25 | + c_sub2ind(dims, indices = ijk), |
| 26 | + c_coords21dindex(xyz_mat[1:2,], origin = origin, voxdims = voxdims, dims = dims)) |
| 27 | + |
| 28 | +}) |
0 commit comments