Closed RobinHankin closed 1 year ago
The following error appears on the CRAN package check results for one of the debian architectures:
── Failure ('test_transform.R:16:9'): Function pullback() behaves itself ─────── issmall(discrepancy) is not TRUE `actual`: FALSE `expected`: TRUE list(index = c(1, 3, 5, 5), value = c(-0.170070938205061, -0.800587236566934)) c(1.46372997954945, 0.4755026057719, 1.18200674579991, 0.197517801699613, -0.276373658487993, 1.1515112794683, -0.187898172031518, 0.924765696304977, -0.232144224280786, 0.96302634681183, 1.30899841041773, 0.621688176410363, -0.324975905380696, -0.0389848423003657, -0.940345853991544, -0.948041906536554, -0.408115650086504, 0.630512116576583, -0.0134038963463815, -0.561589637973832, 1.53093308774001, 0.922058624536413, 0.418724053361834, 0.810188877253954, 2.40135084607294) Backtrace: ▆ 1. └─stokes (local) foo(o, M) at test_transform.R:16:8 2. └─testthat::expect_true(issmall(discrepancy), info = list(x, M)) at test_transform.R:10:8 [snip]
For ease of reference, here is test_transform.R:
test_transform.R
## Some tests of pullback() options(warn=999) test_that("Function pullback() behaves itself", { expect_true(TRUE) foo <- function(x,M){ # checks that pullback(pullback(x,M),solve(M)) == x xt <- pullback(pullback(x,M),solve(M)) discrepancy <- x |> pullback(M) |> pullback(solve(M)) - x expect_true(issmall(discrepancy),info=list(x,M)) } # foo() closes for(i in 1:3){ o <- rform(terms=3,k=2,n=5,coeffs=rnorm(3)) M <- matrix(rnorm(25),5,5) foo(o,M) foo(o*0,M) } })
The information given by testthat is somewhat opaque, but we can generate the error from the dput() as follows:
testthat
dput()
library("stokes") x <- kform(spray(matrix(c(1, 3, 5, 5),2,2),c(-0.170070938205061, -0.800587236566934))) M <- matrix( c(1.46372997954945, 0.4755026057719, 1.18200674579991, 0.197517801699613, -0.276373658487993, 1.1515112794683, -0.187898172031518, 0.924765696304977, -0.232144224280786, 0.96302634681183, 1.30899841041773, 0.621688176410363, -0.324975905380696, -0.0389848423003657, -0.940345853991544, -0.948041906536554, -0.408115650086504, 0.630512116576583, -0.0134038963463815, -0.561589637973832, 1.53093308774001, 0.922058624536413, 0.418724053361834, 0.810188877253954, 2.40135084607294),5,5) discrepancy <- x |> pullback(M) |> pullback(solve(M)) - x discrepancy #> An alternating linear map from V^2 to R with V=R^5: #> val #> 1 3 = 0e+00 #> 3 4 = 1e-07 #> 4 5 = 0e+00 #> 2 5 = 0e+00 #> 3 5 = 0e+00 #> 2 4 = -1e-07 #> 1 5 = 0e+00 #> 1 4 = -1e-07 #> 1 2 = 0e+00 #> 2 3 = 0e+00 coeffs(discrepancy) #> A disord object with hash 5e480a505fb8e76aca638d263498e13b4bb737d9 and elements #> [1] 1.138505e-08 5.612856e-08 8.429197e-09 1.226908e-08 2.023534e-09 #> [6] -9.264841e-08 -2.081617e-09 -6.275604e-08 -2.283195e-08 -3.348759e-08 #> (in some order) issmall(discrepancy) #> [1] FALSE
(the value of x is passed as variable o by foo()). The problem is caused by the small determinant of matrix M:
x
o
foo()
M
det(M) # [1] 0.0001320315
although tbh this is not particularly small, but presumably M is close to some problematic singular value.
Just an observation: function getgood() is general-purpose function, potentially useful in a wide range of situations.
getgood()
The following error appears on the CRAN package check results for one of the debian architectures:
For ease of reference, here is
test_transform.R
:The information given by
testthat
is somewhat opaque, but we can generate the error from thedput()
as follows:(the value of
x
is passed as variableo
byfoo()
). The problem is caused by the small determinant of matrixM
:although tbh this is not particularly small, but presumably
M
is close to some problematic singular value.