[CHNOSZ-commits] r78 - in pkg/CHNOSZ: . R inst inst/tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Mar 6 07:52:51 CET 2015


Author: jedick
Date: 2015-03-06 07:52:51 +0100 (Fri, 06 Mar 2015)
New Revision: 78

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/util.misc.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/inst/tests/test-IAPWS95.R
   pkg/CHNOSZ/inst/tests/test-affinity.R
   pkg/CHNOSZ/inst/tests/test-findit.R
   pkg/CHNOSZ/inst/tests/test-ionize.aa.R
   pkg/CHNOSZ/inst/tests/test-ionize.aa_pK.R
   pkg/CHNOSZ/inst/tests/test-revisit.R
   pkg/CHNOSZ/inst/tests/test-subcrt.R
   pkg/CHNOSZ/inst/tests/test-water.R
   pkg/CHNOSZ/inst/tests/test-wjd.R
Log:
use named 'tolerance' argument in expect_equal() tests


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2015-03-06 01:54:23 UTC (rev 77)
+++ pkg/CHNOSZ/DESCRIPTION	2015-03-06 06:52:51 UTC (rev 78)
@@ -1,6 +1,6 @@
 Date: 2015-03-06
 Package: CHNOSZ
-Version: 1.0.3-15
+Version: 1.0.3-16
 Title: Chemical Thermodynamics and Activity Diagrams
 Author: Jeffrey Dick
 Maintainer: Jeffrey Dick <j3ffdick at gmail.com>

Modified: pkg/CHNOSZ/R/util.misc.R
===================================================================
--- pkg/CHNOSZ/R/util.misc.R	2015-03-06 01:54:23 UTC (rev 77)
+++ pkg/CHNOSZ/R/util.misc.R	2015-03-06 06:52:51 UTC (rev 78)
@@ -84,7 +84,7 @@
     proptable[[i]] <- myprops
     if(didit) ndid <- ndid + 1
   }
-  if(ndid > 0) cat(paste('nonideal:',ndid,'species were nonideal\n'))
+  if(ndid > 0) msgout(paste('nonideal:',ndid,'species were nonideal\n'))
   return(proptable)
 }
 

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2015-03-06 01:54:23 UTC (rev 77)
+++ pkg/CHNOSZ/inst/NEWS	2015-03-06 06:52:51 UTC (rev 78)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.0.3-15 (2015-03-06)
+CHANGES IN CHNOSZ 1.0.3-16 (2015-03-06)
 ---------------------------------------
 
 - Add files with average amino acid compositions of proteins from Bison

Modified: pkg/CHNOSZ/inst/tests/test-IAPWS95.R
===================================================================
--- pkg/CHNOSZ/inst/tests/test-IAPWS95.R	2015-03-06 01:54:23 UTC (rev 77)
+++ pkg/CHNOSZ/inst/tests/test-IAPWS95.R	2015-03-06 06:52:51 UTC (rev 78)
@@ -31,7 +31,7 @@
   expect_equal(residual.calc.1, residual.ref.1, check.attributes=FALSE)
   expect_equal(idealgas.calc.2, idealgas.ref.2, check.attributes=FALSE)
   # ... however an offset is apparent in the value of the residual phi.delta.delta for case 2
-  expect_equal(residual.calc.2, residual.ref.2, check.attributes=FALSE, tol=1e-5)
+  expect_equal(residual.calc.2, residual.ref.2, check.attributes=FALSE, tolerance=1e-5)
 })
 
 test_that("calculations of thermodynamic properties are consistent with reference values", {
@@ -58,21 +58,21 @@
   vapor.calc <- IAPWS95(p, T, rho.vapor)
   ## the tests
   # take P to 5 significant digits but not more than 6 decimals
-  expect_equal(round(signif(liquid.calc$p, 5), 6), P.ref, tol=1e-3)
-  expect_equal(round(signif(vapor.calc$p, 5), 6), P.ref, tol=1e-4)
+  expect_equal(round(signif(liquid.calc$p, 5), 6), P.ref, tolerance=1e-3)
+  expect_equal(round(signif(vapor.calc$p, 5), 6), P.ref, tolerance=1e-4)
   # take H to 6 significant digits but not more than 3 decimals
-  expect_equal(round(signif(liquid.calc$h, 6), 3), H.liquid.ref, tol=1e-5)
+  expect_equal(round(signif(liquid.calc$h, 6), 3), H.liquid.ref, tolerance=1e-5)
   expect_that(round(signif(vapor.calc$h, 6), 3), equals(H.vapor.ref))  # spot on!
   # round S to 4 decimals
   expect_that(round(liquid.calc$s, 4), equals(S.liquid.ref))  # spot on!
-  expect_equal(round(vapor.calc$s, 4), S.vapor.ref, tol=1e-4)
+  expect_equal(round(vapor.calc$s, 4), S.vapor.ref, tolerance=1e-4)
   # round cv to 4 decimals
-  expect_equal(round(liquid.calc$cv, 4), cv.liquid.ref, tol=1e-4)
-  expect_equal(round(vapor.calc$cv, 4), cv.vapor.ref, tol=1e-4)
+  expect_equal(round(liquid.calc$cv, 4), cv.liquid.ref, tolerance=1e-4)
+  expect_equal(round(vapor.calc$cv, 4), cv.vapor.ref, tolerance=1e-4)
   # take cp to 5 significant digits but not more than 4 decimals
   # note high tolerance setting: the highest temperature is the challenge
-  expect_equal(round(signif(liquid.calc$cp, 5), 4), cp.liquid.ref, tol=1e0)
-  expect_equal(round(signif(vapor.calc$cp, 5), 4), cp.vapor.ref, tol=1e-1)
+  expect_equal(round(signif(liquid.calc$cp, 5), 4), cp.liquid.ref, tolerance=1e0)
+  expect_equal(round(signif(vapor.calc$cp, 5), 4), cp.vapor.ref, tolerance=1e-1)
 })
 
 test_that("calculations are possible at low temperatures", {

Modified: pkg/CHNOSZ/inst/tests/test-affinity.R
===================================================================
--- pkg/CHNOSZ/inst/tests/test-affinity.R	2015-03-06 01:54:23 UTC (rev 77)
+++ pkg/CHNOSZ/inst/tests/test-affinity.R	2015-03-06 06:52:51 UTC (rev 78)
@@ -110,7 +110,7 @@
   A.2303RT_max <- apply(A.2303RT, 2, max)
   # we're off a bit in the second decimal ... 
   # maybe becuase of rounding of the aa composition?
-  expect_equal(A.2303RT_max, A.2303RT_ref, 1e-3)
+  expect_equal(A.2303RT_max, A.2303RT_ref, tolerance=1e-3)
   # todo: add comparison with results from loading proteins via species()
 })
 
@@ -125,15 +125,15 @@
   basis("CHNOS")
   # try it with iprotein
   ip <- iprotein("CSG_HALJP")
-  expect_equal(affinity(iprotein=ip)$values[[1]][1], A.2303RT.nonionized, 1e-6)
+  expect_equal(affinity(iprotein=ip)$values[[1]][1], A.2303RT.nonionized, tolerance=1e-6)
   # then with the protein loaded as a species
   species("CSG_HALJP")
-  expect_equal(affinity()$values[[1]][1], A.2303RT.nonionized, 1e-6)
+  expect_equal(affinity()$values[[1]][1], A.2303RT.nonionized, tolerance=1e-6)
   # now for ionized protein
   basis("CHNOS+")
-  expect_equal(affinity(iprotein=ip)$values[[1]][1], A.2303RT.ionized, 1e-6)
+  expect_equal(affinity(iprotein=ip)$values[[1]][1], A.2303RT.ionized, tolerance=1e-6)
   species("CSG_HALJP")
-  expect_equal(affinity()$values[[1]][1], A.2303RT.ionized, 1e-6)
+  expect_equal(affinity()$values[[1]][1], A.2303RT.ionized, tolerance=1e-6)
 })
 
 test_that("affinity() for proteins keeps track of pH on 2-D calculations", {

Modified: pkg/CHNOSZ/inst/tests/test-findit.R
===================================================================
--- pkg/CHNOSZ/inst/tests/test-findit.R	2015-03-06 01:54:23 UTC (rev 77)
+++ pkg/CHNOSZ/inst/tests/test-findit.R	2015-03-06 06:52:51 UTC (rev 78)
@@ -33,9 +33,9 @@
   # sanity check: the output values are all the same length
   expect_equal(length(unique(sapply(f$value, length))), 1)
   # -pi, -e and -sqrt(2) were approximately retrieved!
-  expect_equal(tail(f$value[[1]],1), -pi, tol=1e-2)
-  expect_equal(tail(f$value[[2]],1), -exp(1), tol=1e-2)
-  expect_equal(tail(f$value[[3]],1), -sqrt(2), tol=1e-1)
+  expect_equal(tail(f$value[[1]],1), -pi, tolerance=1e-2)
+  expect_equal(tail(f$value[[2]],1), -exp(1), tolerance=1e-2)
+  expect_equal(tail(f$value[[3]],1), -sqrt(2), tolerance=1e-1)
   # we could decrease the tolerance by increasing the resolution and/or iterations in findit()
 })
 

Modified: pkg/CHNOSZ/inst/tests/test-ionize.aa.R
===================================================================
--- pkg/CHNOSZ/inst/tests/test-ionize.aa.R	2015-03-06 01:54:23 UTC (rev 77)
+++ pkg/CHNOSZ/inst/tests/test-ionize.aa.R	2015-03-06 06:52:51 UTC (rev 78)
@@ -40,10 +40,10 @@
   pH <- c(4, 6, 8, 10, 12, 14)
   # the literature values are significantly different at this tolerance (the following is not TRUE)
   # expect_equal(Z.LYSC_CHICK.25, Z.LYSC_CHICK.100, 1e-1)
-  expect_equal(ionize.aa(aa, pH=pH, T=25)[, 1], Z.LYSC_CHICK.25, 1e-1, check.attributes=FALSE)
-  expect_equal(ionize.aa(aa, pH=pH, T=100)[, 1], Z.LYSC_CHICK.100, 1e-1, check.attributes=FALSE)
-  expect_equal(ionize.aa(aa, pH=pH, T=150)[, 1], Z.LYSC_CHICK.150, 1e-1, check.attributes=FALSE)
-  expect_equal(ionize.aa(aa, pH=pH, T=25, suppress.Cys=TRUE)[, 1], Z.LYSC_CHICK.25_oxid, 1e-2, check.attributes=FALSE)
+  expect_equal(ionize.aa(aa, pH=pH, T=25)[, 1], Z.LYSC_CHICK.25, tolerance=1e-1, check.attributes=FALSE)
+  expect_equal(ionize.aa(aa, pH=pH, T=100)[, 1], Z.LYSC_CHICK.100, tolerance=1e-1, check.attributes=FALSE)
+  expect_equal(ionize.aa(aa, pH=pH, T=150)[, 1], Z.LYSC_CHICK.150, tolerance=1e-1, check.attributes=FALSE)
+  expect_equal(ionize.aa(aa, pH=pH, T=25, suppress.Cys=TRUE)[, 1], Z.LYSC_CHICK.25_oxid, tolerance=1e-2, check.attributes=FALSE)
 })
 
 test_that("heat capacity and Gibbs energy of ionization are consistent with literature", {
@@ -58,8 +58,8 @@
   Cp.ionization.pH12 <- ionize.aa(aa, "Cp", T=c(60, 80, 100, 120, 140), pH=12)
   # the literature values are significantly different at this tolerance (the following is not TRUE)
   # expect_equal(Cp.AMYA_PYRFU.pH6 - Cp.AMYA_PYRFU.nonion, Cp.AMYA_PYRFU.pH12 - Cp.AMYA_PYRFU.nonion, 1e-2)
-  expect_equal(Cp.ionization.pH6[,1], (Cp.AMYA_PYRFU.pH6 - Cp.AMYA_PYRFU.nonion)*1000, 1e-2, check.attributes=FALSE)
-  expect_equal(Cp.ionization.pH12[,1], (Cp.AMYA_PYRFU.pH12 - Cp.AMYA_PYRFU.nonion)*1000, 1e-2, check.attributes=FALSE)
+  expect_equal(Cp.ionization.pH6[,1], (Cp.AMYA_PYRFU.pH6 - Cp.AMYA_PYRFU.nonion)*1000, tolerance=1e-2, check.attributes=FALSE)
+  expect_equal(Cp.ionization.pH12[,1], (Cp.AMYA_PYRFU.pH12 - Cp.AMYA_PYRFU.nonion)*1000, tolerance=1e-2, check.attributes=FALSE)
   # Gibbs energy (Mcal mol-1) of AMY_BACSU at pH 0, 2, 4, 6, 8, 10, 12, 14 at 25 and 100 degrees
   # digitized from Fig. 12 of Dick et al., 2006
   G.AMY_BACSU.25 <- c(-24.9, -24.9, -24.7, -24.5, -24.4, -23.9, -23.5, -23.2)
@@ -70,8 +70,8 @@
   aa <- ip2aa(iprotein("AMY_BACSU"))
   G.ionization.25 <- ionize.aa(aa, "G", T=25, pH=seq(0, 14, 2))[,1]
   G.ionization.100 <- ionize.aa(aa, "G", T=100, pH=seq(0, 14, 2))[,1]
-  expect_equal(G.nonionized[1] + G.ionization.25, G.AMY_BACSU.25 * 1e6, 1e-3, check.attributes=FALSE)
-  expect_equal(G.nonionized[2] + G.ionization.100, G.AMY_BACSU.100 * 1e6, 1e-3, check.attributes=FALSE)
+  expect_equal(G.nonionized[1] + G.ionization.25, G.AMY_BACSU.25 * 1e6, tolerance=1e-3, check.attributes=FALSE)
+  expect_equal(G.nonionized[2] + G.ionization.100, G.AMY_BACSU.100 * 1e6, tolerance=1e-3, check.attributes=FALSE)
   # restore thermo$obigt to original state
   data(thermo)
 })

Modified: pkg/CHNOSZ/inst/tests/test-ionize.aa_pK.R
===================================================================
--- pkg/CHNOSZ/inst/tests/test-ionize.aa_pK.R	2015-03-06 01:54:23 UTC (rev 77)
+++ pkg/CHNOSZ/inst/tests/test-ionize.aa_pK.R	2015-03-06 06:52:51 UTC (rev 78)
@@ -13,15 +13,15 @@
                    `[AABB-]`= c(10.16,7.85, 6.51, 6.28))
   this.pK <- ionize.aa(T=c(0, 100, 200, 300), ret.val="pK")
   # ionization of [Cys] and [His] is off more than the others
-  expect_equal(this.pK[, 1], DLH06.pK$`[Cys-]`, 1e-1, check.attributes=FALSE)
-  expect_equal(this.pK[, 2], DLH06.pK$`[Asp-]`, 1e-2, check.attributes=FALSE)
-  expect_equal(this.pK[, 3], DLH06.pK$`[Glu-]`, 1e-2, check.attributes=FALSE)
-  expect_equal(this.pK[, 4], DLH06.pK$`[His+]`, 1e-1, check.attributes=FALSE)
-  expect_equal(this.pK[, 5], DLH06.pK$`[Lys+]`, 1e-2, check.attributes=FALSE)
-  expect_equal(this.pK[, 6], DLH06.pK$`[Arg+]`, 1e-2, check.attributes=FALSE)
-  expect_equal(this.pK[, 7], DLH06.pK$`[Tyr-]`, 1e-2, check.attributes=FALSE)
-  expect_equal(this.pK[, 8], DLH06.pK$`[AABB+]`,1e-2, check.attributes=FALSE)
-  expect_equal(this.pK[, 9], DLH06.pK$`[AABB-]`,1e-2, check.attributes=FALSE)
+  expect_equal(this.pK[, 1], DLH06.pK$`[Cys-]`, tolerance=1e-1, check.attributes=FALSE)
+  expect_equal(this.pK[, 2], DLH06.pK$`[Asp-]`, tolerance=1e-2, check.attributes=FALSE)
+  expect_equal(this.pK[, 3], DLH06.pK$`[Glu-]`, tolerance=1e-2, check.attributes=FALSE)
+  expect_equal(this.pK[, 4], DLH06.pK$`[His+]`, tolerance=1e-1, check.attributes=FALSE)
+  expect_equal(this.pK[, 5], DLH06.pK$`[Lys+]`, tolerance=1e-2, check.attributes=FALSE)
+  expect_equal(this.pK[, 6], DLH06.pK$`[Arg+]`, tolerance=1e-2, check.attributes=FALSE)
+  expect_equal(this.pK[, 7], DLH06.pK$`[Tyr-]`, tolerance=1e-2, check.attributes=FALSE)
+  expect_equal(this.pK[, 8], DLH06.pK$`[AABB+]`,tolerance=1e-2, check.attributes=FALSE)
+  expect_equal(this.pK[, 9], DLH06.pK$`[AABB-]`,tolerance=1e-2, check.attributes=FALSE)
 })
 
 test_that("there is one pK value for each ionizable group at each temperature", {

Modified: pkg/CHNOSZ/inst/tests/test-revisit.R
===================================================================
--- pkg/CHNOSZ/inst/tests/test-revisit.R	2015-03-06 01:54:23 UTC (rev 77)
+++ pkg/CHNOSZ/inst/tests/test-revisit.R	2015-03-06 06:52:51 UTC (rev 78)
@@ -50,10 +50,10 @@
   r1.qqr <- revisit(e1, "qqr", plot.it=FALSE)
   # the tests will alert us to significant numerical changes
   # but so far haven't been independently verified
-  expect_equal(r1.cv$optimum, 0.30576, tol=1e-5) 
-  expect_equal(r1.sd$optimum, 0.000284694, tol=1e-5) 
-  expect_equal(r1.shannon$optimum, 1.066651, tol=1e-5)
-  expect_equal(r1.qqr$optimum, 0.999783, tol=1e-5)
+  expect_equal(r1.cv$optimum, 0.30576, tolerance=1e-5) 
+  expect_equal(r1.sd$optimum, 0.000284694, tolerance=1e-5) 
+  expect_equal(r1.shannon$optimum, 1.066651, tolerance=1e-5)
+  expect_equal(r1.qqr$optimum, 0.999783, tolerance=1e-5)
 })
 
 test_that("referenced objectives give expected results", {

Modified: pkg/CHNOSZ/inst/tests/test-subcrt.R
===================================================================
--- pkg/CHNOSZ/inst/tests/test-subcrt.R	2015-03-06 01:54:23 UTC (rev 77)
+++ pkg/CHNOSZ/inst/tests/test-subcrt.R	2015-03-06 06:52:51 UTC (rev 78)
@@ -61,14 +61,14 @@
   # 4(2-)propanol(aq) + 3CO2(aq) + 2H2O(l) = 3CH4(aq) + 4lactic acid(aq)
   sout.E12 <- subcrt(c("2-propanol", "CO2", "H2O", "CH4", "lactic acid"), c(-4, -3, -2, 3, 4), T=T)$out
   # now the tests, tolerances set to lowest order of magnitute to pass
-  expect_equal(sout.H2O$G/1000, DG0.H2O, 1e-4)
-  expect_equal(sout.A1$G/1000, DG0.A1, 1e-4)
+  expect_equal(sout.H2O$G/1000, DG0.H2O, tolerance=1e-4)
+  expect_equal(sout.A1$G/1000, DG0.A1, tolerance=1e-4)
   # greater tolerance, our values for NO(aq) differ slightly from AS01
-  expect_equal(sout.NO$G/1000, DG0.NO.aq - DG0.NO.g, 1e-2)
-  expect_equal(sout.B10$G/1000, DG0.B10, 1e-3)
+  expect_equal(sout.NO$G/1000, DG0.NO.aq - DG0.NO.g, tolerance=1e-2)
+  expect_equal(sout.B10$G/1000, DG0.B10, tolerance=1e-3)
   # we can check that sulfur has expected phase transitions
   expect_equal(s.C7$state$sulfur, c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3))
-  expect_equal(sout.C7$G/1000, DG0.C7, 1e-4)
+  expect_equal(sout.C7$G/1000, DG0.C7, tolerance=1e-4)
   # this one is on hold until the HKF parameters of 2-propanol can be located
   #expect_equal(sout.E12$G/1000, DG0.E12, 1e-4)
   # also todo: COS(g) in Amend and Helgeson, 2001 Table 7.2?

Modified: pkg/CHNOSZ/inst/tests/test-water.R
===================================================================
--- pkg/CHNOSZ/inst/tests/test-water.R	2015-03-06 01:54:23 UTC (rev 77)
+++ pkg/CHNOSZ/inst/tests/test-water.R	2015-03-06 06:52:51 UTC (rev 78)
@@ -12,8 +12,8 @@
   # now compare with some real data from Tables V and VI of Fine and Millero, 1973
   T <- convert(c(25, 100), "K")
   P <- c(100, 1000)
-  expect_equal(water.SUPCRT92("beta", T, P)[, 1] * 1e6, c(44.100, 37.002), tol=1e-2)
-  expect_equal(water.SUPCRT92("alpha", T, P)[, 1] * 1e6, c(268.06, 625.55), tol=1e-2)
+  expect_equal(water.SUPCRT92("beta", T, P)[, 1] * 1e6, c(44.100, 37.002), tolerance=1e-2)
+  expect_equal(water.SUPCRT92("alpha", T, P)[, 1] * 1e6, c(268.06, 625.55), tolerance=1e-2)
 })
 
 # reference

Modified: pkg/CHNOSZ/inst/tests/test-wjd.R
===================================================================
--- pkg/CHNOSZ/inst/tests/test-wjd.R	2015-03-06 01:54:23 UTC (rev 77)
+++ pkg/CHNOSZ/inst/tests/test-wjd.R	2015-03-06 06:52:51 UTC (rev 78)
@@ -4,7 +4,7 @@
   # the values from last column of Table III in the paper
   X <- c(0.040668, 0.147730, 0.783153, 0.001414, 0.485247, 0.000693, 0.027399, 0.017947, 0.037314, 0.096872)
   w <- wjd()
-  expect_equal(X, w$X, tol=1e-4)
+  expect_equal(X, w$X, tolerance=1e-4)
 })
 
 test_that("guess() operates on intermediate compositions but fails with endmembers", {
@@ -56,7 +56,7 @@
   e <- equilibrate(a, loga.balance=log10(sum(Y)))
   X.open <- 10^unlist(e$loga.equil)
   # the test: abundances calculated both ways are equal
-  expect_equal(X.closed, X.open, tol=0.019)
+  expect_equal(X.closed, X.open, tolerance=0.019)
   # seems that we could do better than that 1.9% mean difference!
 })
 



More information about the CHNOSZ-commits mailing list