R Under development (unstable) (2024-01-26 r85832 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > require( colorSpec ) Loading required package: colorSpec Attaching colorSpec. Version: 1.5-0. Author: Glenn Davis [aut, cre]. Built: R 4.4.0; ; 2024-01-28 04:15:05 UTC; windows > > # cs.options( loglevel='D' ) > > > # some of the calls below should fail and return NULL, so disable stopping > cs.options( stoponerror=FALSE ) $colorSpec.loglevel [1] "WARN" $colorSpec.logformat [1] "%t{%H:%M:%OS3} %l %n::%f(). %m" $colorSpec.stoponerror [1] FALSE > > testProducts <- function() + { + # find the extdata folder + if( grepl( "[..]Rcheck", getwd() ) ) + extdata = "../colorSpec/extdata" + else + extdata = "inst/extdata" + + extdata = system.file( "extdata", package="colorSpec" ) # override + + if( ! file.exists( extdata ) ) + { + print( getwd() ) + print( extdata ) + cat( "Cannot find the extdata folder !\n" ) + return(FALSE) + } + + # read some materials + IR.blocker = readSpectra( file.path( extdata, "objects/Midwest-SP700-2014.txt" ) ) # 1 spectrum + Hematoxylin = readSpectra( file.path( extdata, "stains/Hematoxylin.txt" ) ) # 1 spectrum + Hoya = readSpectra( file.path( extdata, "objects/Hoya.txt" ) ) # 4 spectra + Rosco = readSpectra( file.path( extdata, "objects/Rosco.txt" ) ) # 42 spectra + + # read some sources + Lumencor = readSpectra( file.path( extdata, "sources/Lumencor-SpectraX.txt" ), 380:720 ) # 7 spectra + + print( getwd() ) + + # create an RGB camera from 3 filters and 1 sensor + Zyla = readSpectra( file.path( extdata, "cameras/Zyla_sCMOS.txt" ) ) # 1 spectrum + cameraRGB = product( subset(Hoya,1:3), Zyla, wave='auto' ) # 3 spectra + + # create an RGB scanner + scannerRGB = product( D65.1nm, 'MATERIAL', cameraRGB, wave='auto' ) # 3 spectra + # summary( scanner ) + + # 4 product types return a colorSpec object + + cat( "-------------- M * ... * M ------------------\n" ) + junk = product( IR.blocker, Hoya, Hematoxylin, wave='auto' ) + if( is.null(junk) ) return(FALSE) + + junk = product( Hoya, Rosco, wave='auto' ) # this should fail + if( ! is.null(junk) ) return(FALSE) + + + cat( "-------------- L * M * ... * M ------------------\n" ) + junk = product( D50.5nm, Hoya, IR.blocker, wave='auto' ) + if( is.null(junk) ) return(FALSE) + + junk = product( Lumencor, Hoya, IR.blocker, wave='auto' ) # this should fail + if( ! is.null(junk) ) return(FALSE) + + + cat( "-------------- M * ... * M * R_L ------------------\n" ) + junk = product( Hoya, IR.blocker, Zyla, wave='auto' ) + if( is.null(junk) ) return(FALSE) + + junk = product( subset(Hoya,1:3), IR.blocker, cameraRGB, wave='auto' ) + if( is.null(junk) ) return(FALSE) + + junk = product( Hoya, IR.blocker, cameraRGB, wave='auto' ) # this should fail + if( ! is.null(junk) ) return(FALSE) + + + cat( "-------------- L * M * 'VARMAT' * M * ... * M * R_L ------------------\n" ) + junk = product( Lumencor, IR.blocker, 'VARMAT', Zyla, wave='auto' ) + if( is.null(junk) ) return(FALSE) + + junk = product( Lumencor, IR.blocker, 'VARMAT', cameraRGB, wave='auto' ) # this should fail + if( ! is.null(junk) ) return(FALSE) + + + + # 2 product types return a matrix + + cat( "-------------- L * M * ... * M * R_L ------------------\n" ) + junk = product( D50.5nm, IR.blocker, Hoya, cameraRGB, wave='auto' ) # junk should be a 4 x 3 matrix + if( is.null(junk) ) return(FALSE) + if( ! all( dim(junk) == c(4,3) ) ) return(FALSE) + + junk = product( Lumencor, IR.blocker, cameraRGB, wave='auto' ) # junk should be a 7 x 3 matrix + if( is.null(junk) ) return(FALSE) + if( ! all( dim(junk) == c(7,3) ) ) return(FALSE) + + junk = product( Lumencor, IR.blocker, Hoya, cameraRGB, wave='auto' ) # this should fail + if( ! is.null(junk) ) return(FALSE) + + + cat( "-------------- M * ... * M * R_M ------------------\n" ) + junk = product( IR.blocker, Rosco, scannerRGB, wave='auto' ) # junk should be a 42 x 3 matrix + if( is.null(junk) ) return(FALSE) + if( ! all( dim(junk) == c(42,3) ) ) return(FALSE) + + junk = product( IR.blocker, Hoya, IR.blocker, Rosco, scannerRGB, wave='auto' ) # this should fail + if( ! is.null(junk) ) return(FALSE) + + + + # some invalid sequences + cat( "-------------- M * ... * M * L ------------------\n" ) + junk = product( IR.blocker, Hoya, Hematoxylin, D50.5nm, wave='auto' ) # this should fail + if( ! is.null(junk) ) return(FALSE) + + cat( "-------------- M * ... * L * M ------------------\n" ) + junk = product( IR.blocker, Hoya, D50.5nm, Hematoxylin, wave='auto' ) # this should fail + if( ! is.null(junk) ) return(FALSE) + + cat( "-------------- L * L * R_L ------------------\n" ) + junk = product( D50.5nm, D65.1nm, cameraRGB, wave='auto' ) # this should fail + if( ! is.null(junk) ) return(FALSE) + + cat( "-------------- L * R_M ------------------\n" ) + junk = product( D50.5nm, scannerRGB, wave='auto' ) # this should fail + if( ! is.null(junk) ) return(FALSE) + + + cat( "\nPassed all product tests !\n" ) + + return( TRUE ) + } > > > if( ! testProducts() ) stop( "testProducts() failed !" ) [1] "d:/RCompile/CRANincoming/R-devel/colorSpec.Rcheck/tests" -------------- M * ... * M ------------------ spectra = [1] 4 42 05:16:16.704 ERROR colorSpec::product.colorSpec(). # of spectra in list is invalid. -------------- L * M * ... * M ------------------ spectra = [1] 7 4 1 05:16:16.712 ERROR colorSpec::product.colorSpec(). # of spectra in list is invalid. -------------- M * ... * M * R_L ------------------ spectra = [1] 4 1 3 05:16:16.754 ERROR colorSpec::product.colorSpec(). # of spectra in list is invalid. -------------- L * M * 'VARMAT' * M * ... * M * R_L ------------------ spectra = [1] 7 1 1 3 05:16:16.762 ERROR colorSpec::product.colorSpec(). # of spectra in list is invalid. -------------- L * M * ... * M * R_L ------------------ spectra = [1] 7 1 4 3 05:16:16.789 ERROR colorSpec::product.colorSpec(). # of spectra in list is invalid. -------------- M * ... * M * R_M ------------------ spectra = [1] 1 4 1 42 3 05:16:16.800 ERROR colorSpec::product.colorSpec(). # of spectra in list is invalid. -------------- M * ... * M * L ------------------ 05:16:16.801 ERROR colorSpec::returnTypeProduct(). Cannot form a product. The types of the colorSpec objects are invalid 05:16:16.801 ERROR colorSpec::product.colorSpec(). Cannot form product, because the argument sequence is invalid. -------------- M * ... * L * M ------------------ 05:16:16.802 ERROR colorSpec::returnTypeProduct(). type(D50.5nm) = 'light' which is invalid for list interior. It must be 'material'. 05:16:16.802 ERROR colorSpec::product.colorSpec(). Cannot form product, because the argument sequence is invalid. -------------- L * L * R_L ------------------ 05:16:16.803 ERROR colorSpec::returnTypeProduct(). type(D65.1nm) = 'light' which is invalid for list interior. It must be 'material'. 05:16:16.803 ERROR colorSpec::product.colorSpec(). Cannot form product, because the argument sequence is invalid. -------------- L * R_M ------------------ 05:16:16.803 ERROR colorSpec::returnTypeProduct(). Cannot form a product. The types of the colorSpec objects are invalid 05:16:16.803 ERROR colorSpec::product.colorSpec(). Cannot form product, because the argument sequence is invalid. Passed all product tests ! > > > > proc.time() user system elapsed 1.10 0.07 1.17