Skip to content

Commit 1dbdbab

Browse files
committed
Fix macOS failures?
Try to revert changes to compile() function to match main version and only add BLAS/LAPACK changes. Use expect_equal instead of identical to eliminate small floating point errors
1 parent e18d2ed commit 1dbdbab

2 files changed

Lines changed: 25 additions & 28 deletions

File tree

R/quick.R

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,11 @@ compile <- function(fsub, build_dir = tempfile(paste0(fsub@name, "-build-"))) {
228228
BLAS_LIBS <- strsplit(cfg("BLAS_LIBS"), "[[:space:]]+")[[1]]
229229
LAPACK_LIBS <- strsplit(cfg("LAPACK_LIBS"), "[[:space:]]+")[[1]]
230230
FLIBS <- strsplit(cfg("FLIBS"), "[[:space:]]+")[[1]]
231-
# clean empties
232231
BLAS_LIBS <- BLAS_LIBS[nzchar(BLAS_LIBS)]
233232
LAPACK_LIBS <- LAPACK_LIBS[nzchar(LAPACK_LIBS)]
234233
FLIBS <- FLIBS[nzchar(FLIBS)]
235-
236234
link_flags <- c(LAPACK_LIBS, BLAS_LIBS, FLIBS)
237235

238-
use_openmp <- FALSE
239-
if (!is.null(fsub@scope)) {
240-
use_openmp <- isTRUE(attr(fsub@scope, "uses_openmp", exact = TRUE))
241-
}
242-
fcompiler_env <- quickr_fcompiler_env(build_dir, use_openmp = use_openmp)
243-
244236
suppressWarnings({
245237
r_args <- c(
246238
"CMD SHLIB --use-LTO",
@@ -250,14 +242,19 @@ compile <- function(fsub, build_dir = tempfile(paste0(fsub@name, "-build-"))) {
250242
c_wrapper_path,
251243
link_flags
252244
)
245+
use_openmp <- isTRUE(attr(fsub@scope, "uses_openmp", exact = TRUE))
246+
env <- quickr_fcompiler_env(
247+
build_dir = build_dir,
248+
use_openmp = use_openmp
249+
)
253250
result <- system2(
254251
R.home("bin/R"),
255252
r_args,
256253
stdout = TRUE,
257254
stderr = TRUE,
258-
env = fcompiler_env
255+
env = env
259256
)
260-
if (!is.null(attr(result, "status")) && length(fcompiler_env)) {
257+
if (!is.null(attr(result, "status")) && length(env)) {
261258
result2 <- system2(
262259
R.home("bin/R"),
263260
r_args,

tests/testthat/test-matrix-mul.R

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ test_that("matrix multiplication matches R for common shapes", {
4848
mat_3x4 <- matrix(rnorm(3 * 4), nrow = 3)
4949
vec_4 <- rnorm(4)
5050

51-
expect_quick_identical(mat_mat, list(mat_A = mat_A, mat_B = mat_B))
52-
expect_quick_identical(
51+
expect_quick_equal(mat_mat, list(mat_A = mat_A, mat_B = mat_B))
52+
expect_quick_equal(
5353
mat_mat_square,
5454
list(mat_A = mat_sq_A, mat_B = mat_sq_B)
5555
)
56-
expect_quick_identical(vec_mat, list(vec = vec_3, mat_A = mat_3x4))
57-
expect_quick_identical(mat_vec, list(mat_A = mat_3x4, vec = vec_4))
58-
expect_quick_identical(vec_vec, list(vec_A = vec_3, vec_B = vec_3))
56+
expect_quick_equal(vec_mat, list(vec = vec_3, mat_A = mat_3x4))
57+
expect_quick_equal(mat_vec, list(mat_A = mat_3x4, vec = vec_4))
58+
expect_quick_equal(vec_vec, list(vec_A = vec_3, vec_B = vec_3))
5959
})
6060

6161
test_that("matrix multiplication handles transposed operands", {
@@ -89,9 +89,9 @@ test_that("matrix multiplication handles transposed operands", {
8989
y_right <- matrix(rnorm(5 * 3), nrow = 5)
9090
y_both <- matrix(rnorm(5 * 4), nrow = 5)
9191

92-
expect_quick_identical(matmul_t_left, list(x = x, y = y_left))
93-
expect_quick_identical(matmul_t_right, list(x = x, y = y_right))
94-
expect_quick_identical(matmul_t_both, list(x = x, y = y_both))
92+
expect_quick_equal(matmul_t_left, list(x = x, y = y_left))
93+
expect_quick_equal(matmul_t_right, list(x = x, y = y_right))
94+
expect_quick_equal(matmul_t_both, list(x = x, y = y_both))
9595
})
9696

9797
test_that("matrix multiplication handles chained mixes", {
@@ -109,7 +109,7 @@ test_that("matrix multiplication handles chained mixes", {
109109
b <- matrix(rnorm(5 * 3), nrow = 5)
110110
c <- matrix(rnorm(5 * 5), nrow = 5)
111111

112-
expect_quick_identical(chain_mix, list(a = a, b = b, c = c))
112+
expect_quick_equal(chain_mix, list(a = a, b = b, c = c))
113113
})
114114

115115
test_that("matrix multiplication handles 1x1 and 1xN/Nx1 shapes", {
@@ -212,8 +212,8 @@ test_that("crossprod and tcrossprod match R", {
212212
x <- matrix(rnorm(6 * 4), nrow = 6)
213213
y <- matrix(rnorm(6 * 4), nrow = 6)
214214

215-
expect_quick_identical(cross_fun, list(x = x, y = y))
216-
expect_quick_identical(tcross_fun, list(x = x, y = y))
215+
expect_quick_equal(cross_fun, list(x = x, y = y))
216+
expect_quick_equal(tcross_fun, list(x = x, y = y))
217217
})
218218

219219
test_that("single-argument crossprod/tcrossprod match R", {
@@ -241,10 +241,10 @@ test_that("single-argument crossprod/tcrossprod match R", {
241241
x <- matrix(rnorm(5 * 4), nrow = 5)
242242
v <- rnorm(5)
243243

244-
expect_quick_identical(cross_single, list(x = x))
245-
expect_quick_identical(tcross_single, list(x = x))
246-
expect_quick_identical(cross_vec, list(x = v))
247-
expect_quick_identical(tcross_vec, list(x = v))
244+
expect_quick_equal(cross_single, list(x = x))
245+
expect_quick_equal(tcross_single, list(x = x))
246+
expect_quick_equal(cross_vec, list(x = v))
247+
expect_quick_equal(tcross_vec, list(x = v))
248248
})
249249

250250
test_that("outer supports multiplication and %o%", {
@@ -276,9 +276,9 @@ test_that("outer supports multiplication and %o%", {
276276
x <- rnorm(3)
277277
y <- rnorm(4)
278278

279-
expect_quick_identical(outer_default, list(x = x, y = y))
280-
expect_quick_identical(outer_mul, list(x = x, y = y))
281-
expect_quick_identical(outer_op, list(x = x, y = y))
279+
expect_quick_equal(outer_default, list(x = x, y = y))
280+
expect_quick_equal(outer_mul, list(x = x, y = y))
281+
expect_quick_equal(outer_op, list(x = x, y = y))
282282
})
283283

284284
test_that("outer errors on unsupported FUN", {

0 commit comments

Comments
 (0)