R Under development (unstable) (2025-06-17 r88325 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 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. > > library( munsellinterpol ) > > options( width=144 ) > > # > # checkColorLookup() > # performs lookup with ColorBlockFromMunsell() and verifies that the color block number is correct > # > # return value: TRUE or FALSE > # > testRounding <- function( count=100 ) + { + set.seed(0) + + # make hues that are in the book + countbad = 0 + + # make vector of Hues that actually appear in the soil book + hueseq = c( seq(5,25,by=2.5), seq(30,75,by=5) ) + + for( hue in hueseq ) + { + mess = sprintf( "------------------- Hue %s ---------------------\n", HueStringFromNumber(hue) ) + cat( mess ) + + HVC = cbind( hue, runif(count,min=2,max=8), runif(count,min=1,max=8) ) + + dat = roundHVC( HVC, book='soil' ) + + # hopefully all the rounded hues are hue + HVCrnd = HVCfromMunsellName( dat$MunsellRnd ) + maskbad = HVCrnd[ ,1] != hue + + if( any(maskbad) ) + { + print( dat[maskbad, ] ) + countbad = countbad + sum(maskbad) + + # return(FALSE) + } + } + + # calculate fraction of bad ones + fractionbad = countbad / ( count*length(hueseq) ) + + + cat( "bad count: ", countbad, " of ", count*length(hueseq), " Fraction bad = ", fractionbad, '\n' ) + + return( fractionbad < 0.02 ) + } > > > if( ! testRounding() ) stop( "testRounding() failed !\n" ) ------------------- Hue 5R --------------------- ERROR [2025-06-18 02:00:05] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 7.5R --------------------- ERROR [2025-06-18 02:00:05] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 10R --------------------- ERROR [2025-06-18 02:00:05] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 2.5YR --------------------- ERROR [2025-06-18 02:00:05] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 5YR --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 7.5YR --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 10YR --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 2.5Y --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 5Y --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 10Y --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 5GY --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 10GY --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 5G --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 10G --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 5BG --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 10BG --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 5B --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 10B --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. ------------------- Hue 5PB --------------------- ERROR [2025-06-18 02:00:06] munsellinterpol::HVCfromMunsellName(). MunsellName is not a character vector with positive length. bad count: 0 of 1900 Fraction bad = 0 > > > cat( "Passed rounding test !\n" ) Passed rounding test ! > > proc.time() user system elapsed 1.25 0.18 1.43