Nothing
library(testthat)
library(DistributionalDDA)
## Regression tests for two pre-existing fixes (2026-06-25):
## - as.BDataSplines(x, basis = otherBasis) must return a *classed* BDataSplines.
## The reproject path used to return a bare matrix, so downstream methods (e.g.
## scalarProduct, which reprojects internally) failed on the result.
## - as.function(basis) must evaluate the ZB-spline basis. A dead, shadowed
## duplicate of as.function.BayesSpaceBasis (classes.R) referenced a free `A`;
## it was removed. The live method (Bayes_spaces.R) goes through basisEval and
## therefore basis$A.
test_that("as.BDataSplines onto a different basis returns a classed BDataSplines", {
set.seed(3)
p5 <- getBayesSpaceBasisDimension(B2Unif01Basis5)
p7 <- getBayesSpaceBasisDimension(B2Unif01Basis7)
X5 <- BDataSplines(matrix(rnorm(3 * p5), nrow = 3), B2Unif01Basis5)
Y7 <- as.BDataSplines(X5, basis = B2Unif01Basis7)
expect_s3_class(Y7, "BDataSplines")
expect_equal(numberOfCases(Y7), 3)
expect_equal(ncol(unclass(Y7)), p7)
## a single observation must stay a one-row BDataSplines, not collapse
X1 <- BDataSplines(matrix(rnorm(p5), nrow = 1), B2Unif01Basis5)
Y1 <- as.BDataSplines(X1, basis = B2Unif01Basis7)
expect_s3_class(Y1, "BDataSplines")
expect_equal(numberOfCases(Y1), 1)
## the result is usable by downstream methods that reproject it internally
## (previously failed because as.BDataSplines handed back a bare matrix)
sp <- scalarProduct(X5, Y7)
expect_equal(dim(sp), c(3L, 3L))
expect_true(all(is.finite(sp)))
})
test_that("as.function(basis) evaluates the ZB-spline basis (basis$A, not a free A)", {
x <- seq(0, 1, length.out = 11)
for (basis in list(B2Unif01Basis5, B2Unif01Basis7)) {
fb <- as.function(basis)
expect_equal(unname(fb(x)), unname(basisEval(basis, x)), tolerance = 1e-10)
}
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.