Skip to content
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
6 changes: 6 additions & 0 deletions nCompiler/R/typeDeclarations.R
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,12 @@ type2symbol <- function(type,
# return(ans)
# }

if(ttypeToUse |> rlang::get_expr() |> inherits("symbolBase")) {
ans <- ttypeToUse |> rlang::get_expr()
ans$name <- name
return(ans)
}

typeSpec <- nTypeSpec(ttypeToUse)
inputAsLiteral <- identical(rlang::quo_get_env(ttypeToUse), emptyenv())
inputAsCharacter <- typeSpec$inputAsCharacter
Expand Down
14 changes: 11 additions & 3 deletions nCompiler/tests/testthat/nimble_tests/test-compileNimble.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## The real tests will be running nimble's test suite.

library(nimble)
#library(nCompiler)
library(nCompiler)
library(testthat)

test_that("compileNimble bridge works for simple nimbleFunction (RC function)",{
Expand All @@ -14,7 +14,7 @@ test_that("compileNimble bridge works for simple nimbleFunction (RC function)",{
returnType(double())
}
)
CRCF1 <- `:::`("nCompiler", "compileNimble")(RCF1)
CRCF1 <- nCompiler:::compileNimble(RCF1)
expect_equal(CRCF1(1:3), 6)
})

Expand All @@ -24,7 +24,7 @@ test_that("compileNimble bridge works for one nimbleFunction object", {
run = function() {return(x[1]); returnType(double())}
)
nf1 <- nf()
Cnf1 <- `:::`("nCompiler", "compileNimble")(nf1)
Cnf1 <- nCompiler:::compileNimble(nf1)
expect_identical(Cnf1$x, 1:2)
})
## NEXT STEPS:
Expand All @@ -33,3 +33,11 @@ test_that("compileNimble bridge works for one nimbleFunction object", {
## add nClass to nCompiler:::compileNimble
##
## document, document, document


test <- nClass(
Cpublic = list(
x = nTypeBasic(name = "x", scalarType = "integer", nDim = 1)
)
)
ctest <- nCompile(test)
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,17 @@ test_that("tensorOperations with re-shaping for single ops", {
expect_identical(opfun(V1, A3), op_v_a3(x = V1, y = A3))

# nCompiler runtime errors on non-conformable inputs
cat("Next error message is expected:\n")
expect_error(op_m_m(x = M1, y = M2))
cat("Next error message is expected:\n")
expect_error(op_m_m(x = M1, y = M3))
cat("Next error message is expected:\n")
expect_error(op_m_m(x = M1, y = M4))

# nCompiler runtime errors where R would normally use recycling rule
cat("Next error message is expected:\n")
expect_error(op_m_v(x = M3, y = V1))
cat("Next error message is expected:\n")
expect_error(op_v_a3(x = V1, y = A4))

# # Issues: These should throw errors, but don't. Are runtime args validated?
Expand Down
Loading