[CHNOSZ-commits] r768 - in pkg/CHNOSZ: . inst/tinytest

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Feb 20 03:33:09 CET 2023


Author: jedick
Date: 2023-02-20 03:33:09 +0100 (Mon, 20 Feb 2023)
New Revision: 768

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/inst/tinytest/test-AD.R
   pkg/CHNOSZ/inst/tinytest/test-DEW.R
   pkg/CHNOSZ/inst/tinytest/test-IAPWS95.R
   pkg/CHNOSZ/inst/tinytest/test-add.protein.R
   pkg/CHNOSZ/inst/tinytest/test-affinity.R
   pkg/CHNOSZ/inst/tinytest/test-basis.R
   pkg/CHNOSZ/inst/tinytest/test-buffer.R
   pkg/CHNOSZ/inst/tinytest/test-diagram.R
   pkg/CHNOSZ/inst/tinytest/test-eos.R
   pkg/CHNOSZ/inst/tinytest/test-equilibrate.R
   pkg/CHNOSZ/inst/tinytest/test-info.R
   pkg/CHNOSZ/inst/tinytest/test-ionize.aa.R
   pkg/CHNOSZ/inst/tinytest/test-ionize.aa_pK.R
   pkg/CHNOSZ/inst/tinytest/test-logmolality.R
   pkg/CHNOSZ/inst/tinytest/test-makeup.R
   pkg/CHNOSZ/inst/tinytest/test-mosaic.R
   pkg/CHNOSZ/inst/tinytest/test-nonideal.R
   pkg/CHNOSZ/inst/tinytest/test-protein.info.R
   pkg/CHNOSZ/inst/tinytest/test-recalculate.R
   pkg/CHNOSZ/inst/tinytest/test-solubility.R
   pkg/CHNOSZ/inst/tinytest/test-species.R
   pkg/CHNOSZ/inst/tinytest/test-subcrt.R
   pkg/CHNOSZ/inst/tinytest/test-swap.basis.R
   pkg/CHNOSZ/inst/tinytest/test-thermo.R
   pkg/CHNOSZ/inst/tinytest/test-util.R
   pkg/CHNOSZ/inst/tinytest/test-util.affinity.R
   pkg/CHNOSZ/inst/tinytest/test-util.data.R
   pkg/CHNOSZ/inst/tinytest/test-util.expression.R
   pkg/CHNOSZ/inst/tinytest/test-util.program.R
   pkg/CHNOSZ/inst/tinytest/test-util.seq.R
   pkg/CHNOSZ/inst/tinytest/test-water.R
   pkg/CHNOSZ/inst/tinytest/test-water.lines.R
Log:
Capitalize comments and add 'info' argument to some tests


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2023-02-20 01:50:55 UTC (rev 767)
+++ pkg/CHNOSZ/DESCRIPTION	2023-02-20 02:33:09 UTC (rev 768)
@@ -1,6 +1,6 @@
 Date: 2023-02-20
 Package: CHNOSZ
-Version: 1.9.9-59
+Version: 1.9.9-60
 Title: Thermodynamic Calculations and Diagrams for Geochemistry
 Authors at R: c(
     person("Jeffrey", "Dick", , "j3ffdick at gmail.com", role = c("aut", "cre"),

Modified: pkg/CHNOSZ/inst/tinytest/test-AD.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-AD.R	2023-02-20 01:50:55 UTC (rev 767)
+++ pkg/CHNOSZ/inst/tinytest/test-AD.R	2023-02-20 02:33:09 UTC (rev 768)
@@ -48,7 +48,7 @@
 info <- "AD gives consistent values of G, H, and S"
 T_in_Kelvin <- convert(T, "K")
 S_of_elements_in_Joules <- entropy("CO2")
-expect_equal(sout2$H - T_in_Kelvin * sout2$S + 298.15 * S_of_elements_in_Joules, sout2$G)
+expect_equal(sout2$H - T_in_Kelvin * sout2$S + 298.15 * S_of_elements_in_Joules, sout2$G, info = info)
 
 # 20220206
 info <- "Fugacity, density, and density derivatives of H2O are close to values in Akinfiev and Diamond (2003)"

Modified: pkg/CHNOSZ/inst/tinytest/test-DEW.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-DEW.R	2023-02-20 01:50:55 UTC (rev 767)
+++ pkg/CHNOSZ/inst/tinytest/test-DEW.R	2023-02-20 02:33:09 UTC (rev 768)
@@ -110,7 +110,7 @@
 # (at P=5000 bar this depends on calculating drhodP -> beta -> dgdP -> dwdP -> V correctly, which is not tested above)
 expect_equal(c(R1$V, R2$V, R3$V), DEW_DV[1:6], tolerance = 1e-15, info = info)
 # TODO: why does DEW spreadsheet use V (O2,g) == 24.465?
-#expect_equal(c(R4$V, R5$V), DEW_DV[7:10])
+#expect_equal(c(R4$V, R5$V), DEW_DV[7:10], info = info)
 
 info <- "Calculated logK values are consistent with Extended Deep Earth Water paper"
 # Reference logK values are from Appendix D of Huang and Sverjensky, 2019 (doi:10.1016/j.gca.2019.03.027)

Modified: pkg/CHNOSZ/inst/tinytest/test-IAPWS95.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-IAPWS95.R	2023-02-20 01:50:55 UTC (rev 767)
+++ pkg/CHNOSZ/inst/tinytest/test-IAPWS95.R	2023-02-20 02:33:09 UTC (rev 768)
@@ -62,9 +62,9 @@
 expect_equal(round(signif(vapor.calc$p, 5), 6), P.ref, tolerance = 1e-4, info = info)
 # Take H to 6 significant digits but not more than 3 decimals
 expect_equal(round(signif(liquid.calc$h, 6), 3), H.liquid.ref, tolerance = 1e-5, info = info)
-expect_equal(round(signif(vapor.calc$h, 6), 3), H.vapor.ref)  # spot on!
+expect_equal(round(signif(vapor.calc$h, 6), 3), H.vapor.ref, info = info)  # spot on!
 # Round S to 4 decimals
-expect_equal(round(liquid.calc$s, 4), S.liquid.ref)  # spot on!
+expect_equal(round(liquid.calc$s, 4), S.liquid.ref, info = info)  # spot on!
 expect_equal(round(vapor.calc$s, 4), S.vapor.ref, tolerance = 1e-4, info = info)
 # Round cv to 4 decimals
 expect_equal(round(liquid.calc$cv, 4), cv.liquid.ref, tolerance = 1e-4, info = info)

Modified: pkg/CHNOSZ/inst/tinytest/test-add.protein.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-add.protein.R	2023-02-20 01:50:55 UTC (rev 767)
+++ pkg/CHNOSZ/inst/tinytest/test-add.protein.R	2023-02-20 02:33:09 UTC (rev 768)
@@ -2,12 +2,12 @@
 reset()
 
 info <- "add.protein works as expected"
-# factors causing problems again ...
+# Factors causing problems again ...
 f <- system.file("extdata/protein/POLG.csv", package = "CHNOSZ")
 aa <- read.csv(f, as.is = TRUE)
-# this adds the proteins
+# This adds the proteins
 ip1 <- add.protein(aa)
-# the replaces the proteins (with the same ones)
+# This replaces the proteins (with the same ones)
 ip2 <- add.protein(aa)
 expect_equal(ip1, ip2, info = info)
 
@@ -16,13 +16,13 @@
 expect_message(add.protein(pinfo(pinfo("CYC_BOVIN"))), "replaced 1 existing protein\\(s\\)", info = info)
 
 info <- "group additivity for proteins gives expected values"
-# values for chicken lysozyme calculated using group additivity values
+# Values for chicken lysozyme calculated using group additivity values
 # from Dick et al., 2006 [DLH06] (Biogeosciences 3, 311-336)
 G <- -4206050
 Cp <- 6415.5
 V <- 10421
 formula <- "C613H959N193O185S10"
-# to reproduce, use superseded properties of [Met], [Gly], and [UPBB] (Dick et al., 2006)
+# To reproduce, use superseded properties of [Met], [Gly], and [UPBB] (Dick et al., 2006)
 mod.OBIGT("[Met]", G = -35245, H = -59310, S = 40.38)
 mod.OBIGT("[Gly]", G = -6075, H = -5570, S = 17.31)
 mod.OBIGT("[UPBB]", G = -21436, H = -45220, S = 1.62)
@@ -35,21 +35,10 @@
 info <- "read.fasta() identifies sequences correctly and gives amino acid compositions in the correct format"
 ffile <- system.file("extdata/protein/EF-Tu.aln", package = "CHNOSZ")
 aa <- read.fasta(ffile)
-expect_equal(aa[1, ], read.fasta(ffile, 1))
-# use unlist here so that different row names are not compared
+expect_equal(aa[1, ], read.fasta(ffile, 1), info = info)
+# Use unlist here so that different row names are not compared
 expect_equal(unlist(aa[8, ]), unlist(read.fasta(ffile, 8)), info = info)
 expect_message(ip1 <- add.protein(aa), "added 8 new protein\\(s\\)", info = info)
 expect_message(ip2 <- add.protein(aa), "replaced 8 existing protein\\(s\\)", info = info)
 # add.protein should return the correct indices for existing proteins
 expect_equal(ip1, ip2, info = info)
-
-# for the future... make info() faster!
-# (especially the loading of ionizable groups for proteins)
-#test_that("calculations for ionized proteins meet performance expectations", {
-#  expect_that({
-#    basis("CHNOS+")
-#    i <- info(c("LYSC_CHICK","RNAS1_BOVIN"))
-#    species(i)
-#    a <- affinity()
-#  }, takes_less_than(0.4))
-#})

Modified: pkg/CHNOSZ/inst/tinytest/test-affinity.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-affinity.R	2023-02-20 01:50:55 UTC (rev 767)
+++ pkg/CHNOSZ/inst/tinytest/test-affinity.R	2023-02-20 02:33:09 UTC (rev 768)
@@ -27,7 +27,7 @@
 expect_equal(range(a.K_MPa$vals[[2]]), c(1, 100), info = info)
 # different units, same T,P ... same affinities
 expect_equal(a.C_bar$values, a.K_MPa$values, info = info)
-# go back to original units for the remaining tests
+# Go back to original units for the remaining tests
 T.units("C")
 P.units("bar")
 
@@ -38,12 +38,12 @@
 pe <- convert(Eh, "pe", T = convert(100, "K"))
 a.Eh <- affinity(Eh = Eh, T = 100)
 a.pe <- affinity(pe = pe, T = 100)
-# they should give the same result
+# They should give the same result
 # ... except for names(dim(.)), so set check.attributes = FALSE
 expect_equal(a.Eh$values, a.pe$values, check.attributes = FALSE, info = info)
-# the variables should have the right names
+# The variables should have the right names
 expect_equal(c(a.Eh$vars, a.pe$vars), c("Eh", "pe"), info = info)
-# now for an Eh-pH example
+# Now for an Eh-pH example
 pH <- c(0, 14)
 a <- affinity(pH = pH, Eh = Eh)
 expect_equal(a$vars, c("pH", "Eh"), info = info)
@@ -50,7 +50,7 @@
 expect_equal(range(a$vals[[1]]), pH, info = info)
 expect_equal(range(a$vals[[2]]), Eh, info = info)
 expect_equal(length(a$vals[[2]]), 256, info = info)
-# since Eh has to be reconstructed, check it's done correctly
+# Since Eh has to be reconstructed, check it's done correctly
 a129 <- affinity(pH = pH, Eh = c(Eh, 129))
 expect_equal(length(a129$vals[[2]]), 129, info = info)
 
@@ -62,61 +62,61 @@
 ##a <- affinity(T = T, Eh = Eh, pH = pH)
 
 info <- "affinity() in 3D returns values consistent with manual calculation"
-# our "manual" calculation will be for H2(aq) + 0.5O2(aq) = H2O(l)
-# the equilibrium constants at 25 and 100 degrees C
+# Our "manual" calculation will be for H2(aq) + 0.5O2(aq) = H2O(l)
+# The equilibrium constants at 25 and 100 degrees C
 # (the logK are tested against literature values in test-subcrt.R)
 logK.25 <- subcrt(c("H2", "O2", "H2O"), "aq", c(-1, -0.5, 1), T = 25)$out$logK
 logK.100 <- subcrt(c("H2", "O2", "H2O"), "aq", c(-1, -0.5, 1), T = 100)$out$logK
-# the value of A/2.303RT at 25 degrees and logaH2 = -10, logaO2 = -10 and logaH2O = 0
+# The value of A/2.303RT at 25 degrees and logaH2 = -10, logaO2 = -10 and logaH2O = 0
 A.2303RT.25.10.10 <- logK.25 - ( (-1)*(-10) + (-0.5)*(-10) )
-# the value of A/2.303RT at 100 degrees and logaH2 = -5, logaO2 = -10 and logaH2O = 0
+# The value of A/2.303RT at 100 degrees and logaH2 = -5, logaO2 = -10 and logaH2O = 0
 A.2303RT.100.5.10 <- logK.100 - ( (-1)*(-5) + (-0.5)*(-10) )
-# set up basis and species
+# Set up basis and species
 basis(c("H2", "O2"), "aq")
 species("H2O")
-# we will run affinity() in 3D
+# We will run affinity() in 3D
 # T = 0, 25, 50, 75, 100, 125 degrees
 # log_a(H2) = -20, -15, -10, -5, 0
 # log_a(O2) = -20, -15, -10, -5, 0
-# first test: the dimensions are correct
+# First test: the dimensions are correct
 a.logK <- affinity(T = c(0, 125, 6), H2 = c(-20, 0, 5), O2 = c(-20, 0, 5), property = "logK")
 expect_equal(dim(a.logK$values[[1]]), c(6, 5, 5), check.names = FALSE, info = info)
-# second and third tests: the logK values used by affinity() are correct
+# Second and third tests: the logK values used by affinity() are correct
 expect_equal(a.logK$values[[1]][2, 3, 3], logK.25, info = info)
 expect_equal(a.logK$values[[1]][5, 4, 3], logK.100, info = info)
-# fourth and fifth tests: the A/2.303RT values returned by affinity() are correct
+# Fourth and fifth tests: the A/2.303RT values returned by affinity() are correct
 a.A <- affinity(T = c(0, 125, 6), H2 = c(-20, 0, 5), O2 = c(-20, 0, 5))
 expect_equal(a.A$values[[1]][2, 3, 3], A.2303RT.25.10.10, info = info)
 expect_equal(a.A$values[[1]][5, 4, 3], A.2303RT.100.5.10, info = info)
 
 info <- "'iprotein' gives consistent results on a transect"
-# from Dick and Shock, 2011, values of A/2.303RT for the per-residue
+# From Dick and Shock, 2011, values of A/2.303RT for the per-residue
 # formation reactions of overall model proteins at five sampling sites
 # at Bison Pool, with different temperature, pH and log_a(H2)
-# these are the maximum values for each site from Table 5 in the paper
+# These are the maximum values for each site from Table 5 in the paper
 A.2303RT_ref <- c(-18.720, -27.894, -35.276, -36.657, -41.888)
-# the measured temperatures and pHs
+# The measured temperatures and pHs
 T <- c(93.3, 79.4, 67.5, 65.3, 57.1)
 pH <- c(7.350, 7.678, 7.933, 7.995, 8.257)
 # Eq. 24 of the paper
 H2 <- -11+T*3/40
-# remove "RESIDUE" entries in thermo()$OBIGT (clutter from first test)
+# Remove "RESIDUE" entries in thermo()$OBIGT (clutter from first test)
 reset()
 basis(c("HCO3-", "H2O", "NH3", "HS-", "H2", "H+"),
   "aq", c(-3, 0, -4, -7, 999, 999))
 sites <- c("N", "S", "R", "Q", "P")
 ip <- pinfo("overall", c("bisonN", "bisonS", "bisonR", "bisonQ", "bisonP"))
-# to reproduce, use superseded properties of [Met], [Gly], and [UPBB] (Dick et al., 2006)
+# To reproduce, use superseded properties of [Met], [Gly], and [UPBB] (Dick et al., 2006)
 mod.OBIGT("[Met]", G = -35245, H = -59310, S = 40.38)
 mod.OBIGT("[Gly]", G = -6075, H = -5570, S = 17.31)
 mod.OBIGT("[UPBB]", G = -21436, H = -45220, S = 1.62)
 a <- affinity(T = T, pH = pH, H2 = H2, iprotein = ip)
-# divide A/2.303RT by protein length
+# Divide A/2.303RT by protein length
 pl <- protein.length(ip)
 A.2303RT <- t(sapply(a$values, c)) / pl
-# find the maximum for each site
+# Find the maximum for each site
 A.2303RT_max <- apply(A.2303RT, 2, max)
-# we're off a bit in the second decimal ... 
+# 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, tolerance = 1e-3, info = info)
 # TODO: add comparison with results from loading proteins via species()
@@ -125,15 +125,15 @@
 # These values were calculated using versions 0.6, 0.8 and 0.9-7 (25 degrees C, 1 bar, basis species "CHNOS" or "CHNOS+")
 A.2303RT.nonionized <- -3795.297
 A.2303RT.ionized <- -3075.222
-# first for nonionized protein
+# First for nonionized protein
 basis("CHNOS")
-# try it with iprotein
+# Try it with iprotein
 ip <- pinfo("CSG_HALJP")
 expect_equal(affinity(iprotein = ip, loga.protein = -3)$values[[1]][1], A.2303RT.nonionized, tolerance = 1e-5, info = info)
-# then with the protein loaded as a species
+# Then with the protein loaded as a species
 species("CSG_HALJP")
 expect_equal(affinity()$values[[1]][1], A.2303RT.nonionized, tolerance = 1e-5, info = info)
-# now for ionized protein
+# Now for ionized protein
 basis("CHNOS+")
 expect_equal(affinity(iprotein = ip, loga.protein = -3)$values[[1]][1], A.2303RT.ionized, tolerance = 1e-5, info = info)
 species("CSG_HALJP")
@@ -148,7 +148,7 @@
 expect_equal(as.numeric(a1$values[[1]]), a2$values[[1]][, 2], info = info)
 
 info <- "IS can be constant or variable"
-# inspired by an error from demo("phosphate")
+# Inspired by an error from demo("phosphate")
 # > a25 <- affinity(IS = c(0, 0.14), T = T[1])
 # ...
 # Error in subcrt(species  =  c(1017L, 20L, 19L), property  =  "logK", T  =  298.15,  : 
@@ -172,18 +172,18 @@
 a2 <- affinity(a0, T = 100)
 a3 <- affinity(a1, T = 25)
 expect_identical(a1, a2, info = info)
-# we don't test entire output here becuase a0 doesn't have a "T" argument
+# We don't test entire output here becuase a0 doesn't have a "T" argument
 expect_identical(a0$values, a3$values, info = info)
 
 info <- "sout is processed correctly"
 # 20190201
 basis("CHNOS+")
-# previously, this test would fail when sout has
+# Previously, this test would fail when sout has
 # more species than are used in the calculation
 species(c("H2S", "CO2", "CH4"))
 a0 <- affinity(T = c(0, 100))
 sout <- a0$sout
-# test the calculation with just CH4
+# Test the calculation with just CH4
 species(1:2, delete = TRUE)
 a1 <- affinity(T = c(0, 100))
 a2 <- affinity(T = c(0, 100), sout = a0$sout)

Modified: pkg/CHNOSZ/inst/tinytest/test-basis.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-basis.R	2023-02-20 01:50:55 UTC (rev 767)
+++ pkg/CHNOSZ/inst/tinytest/test-basis.R	2023-02-20 02:33:09 UTC (rev 768)
@@ -12,8 +12,8 @@
 ina <- nrow(thermo()$OBIGT) + 1
 expect_error(basis(ina), "species not available", info = info)
 expect_error(CHNOSZ:::preset.basis(c("CN")), "is not a keyword", info = info)
-# after all that, the basis should still be undefined
-expect_null(basis())
+# After all that, the basis should still be undefined
+expect_null(basis(), info = info)
 
 info <- "Invalid basis modification requests cause an error"
 basis(delete = TRUE)
@@ -24,16 +24,16 @@
 expect_error(CHNOSZ:::mod.basis(iCH4, "gas"), "is not a species index of one of the basis species", info = info)
 expect_error(CHNOSZ:::mod.basis("CO2", "PPM"), "the elements .* in buffer .* are not in the basis", info = info)
 expect_error(CHNOSZ:::mod.basis("CO2", "liq"), "state .* not found", info = info)
-# after all that, the basis should be unchanged
+# After all that, the basis should be unchanged
 expect_equal(basis(), b, info = info)
 
 info <- "Modifying states of basis species is possible"
 b1 <- basis(c("copper", "chalcocite"))
 b2 <- basis("Cu2S", "cr2")
-# we went from chalcocite cr to cr2, which is the next row in the database
+# We went from chalcocite cr to cr2, which is the next row in the database
 expect_equal(sum(b2$ispecies - b1$ispecies), 1, info = info)
-expect_error(basis("Cu2S", "cr4"), "state or buffer 'cr4' not found for chalcocite")
-# can we go from CO2(aq) to CO2(gas) back to CO2(aq)?
+expect_error(basis("Cu2S", "cr4"), "state or buffer 'cr4' not found for chalcocite", info = info)
+# Can we go from CO2(aq) to CO2(gas) back to CO2(aq)?
 basis("CHNOS+")  # first basis species is CO2(aq)
 expect_equal(basis("CO2", "gas")$state[1], "gas", info = info)
 expect_equal(basis("CO2", "aq")$state[1], "aq", info = info)
@@ -43,13 +43,13 @@
 basis(c("iron", "oxygen", "H2O", "H+"), c(0, -80, 1, -7))
 species(c("Fe", "Fe+2", "Fe+2"), c(0, -6, -6))
 a1 <- affinity(pH = c(0, 14))
-expect_error(basis(c("iron"), add = TRUE), "this species is already in the basis definition")
-expect_error(basis(c("iron", "oxygen", "H2O", "H+"), add = TRUE), "these species are already in the basis definition")
-expect_error(basis("Fe+2", add = TRUE), "the number of basis species is greater than the number of elements and charge")
-expect_silent(newbasis <- basis(c("H2S", "Cl-"), c(-5, -3), add = TRUE))
-expect_equal(newbasis$logact[5:6], c(-5, -3))
+expect_error(basis(c("iron"), add = TRUE), "this species is already in the basis definition", info = info)
+expect_error(basis(c("iron", "oxygen", "H2O", "H+"), add = TRUE), "these species are already in the basis definition", info = info)
+expect_error(basis("Fe+2", add = TRUE), "the number of basis species is greater than the number of elements and charge", info = info)
+expect_silent(newbasis <- basis(c("H2S", "Cl-"), c(-5, -3), add = TRUE), info = info)
+expect_equal(newbasis$logact[5:6], c(-5, -3), info = info)
 newspecies <- species()
-expect_equal(colnames(newspecies)[5:6], c("H2S", "Cl-"))
-expect_equal(newspecies$H2S, numeric(3))
+expect_equal(colnames(newspecies)[5:6], c("H2S", "Cl-"), info = info)
+expect_equal(newspecies$H2S, numeric(3), info = info)
 a2 <- affinity(pH = c(0, 14))
-expect_identical(a1$values, a2$values)
+expect_identical(a1$values, a2$values, info = info)

Modified: pkg/CHNOSZ/inst/tinytest/test-buffer.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-buffer.R	2023-02-20 01:50:55 UTC (rev 767)
+++ pkg/CHNOSZ/inst/tinytest/test-buffer.R	2023-02-20 02:33:09 UTC (rev 768)
@@ -4,15 +4,15 @@
 info <- "Simple buffer works in 0, 1, and 2 dimensions"
 
 add.OBIGT("SUPCRT92")
-# define 4 temperatures
+# Define 4 temperatures
 T <- c(200, 300, 400, 500)
 # calculate SiO2 activity buffered by quartz at 1000 bar
 logaSiO2 <- subcrt(c("quartz", "SiO2"), c(-1, 1), T = T, P = 1000)$out$logK
 
-# set up system
+# Set up system
 basis(c("Al+3", "SiO2", "Na+", "K+", "H2O", "O2", "H+"))
 species(c("K-feldspar", "albite", "paragonite", "dickite", "muscovite"))
-# calculate logact(SiO2) with quartz buffer
+# Calculate logact(SiO2) with quartz buffer
 basis("SiO2", "quartz")
 
 # 0 dimensions: constant T

Modified: pkg/CHNOSZ/inst/tinytest/test-diagram.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-diagram.R	2023-02-20 01:50:55 UTC (rev 767)
+++ pkg/CHNOSZ/inst/tinytest/test-diagram.R	2023-02-20 02:33:09 UTC (rev 768)
@@ -12,30 +12,30 @@
 
 info <- "Expected messages, errors and results arise using output from affinity()"
 basis("CHNOS+")
-# fugacity of O2 is buffered here
+# Fugacity of O2 is buffered here
 basis("O2", "CO2-AC")
 species(c("formic acid", "formate", "acetic acid", "acetate"))
 # 0-D
 a <- affinity()
-# equilibrium activities are not possible here
+# Equilibrium activities are not possible here
 expect_error(diagram(a, "loga.equil"), "'eout' is not the output from equil\\(\\)", info = info)
-# we can't calculate the equilibrium activity of a basis species if it's externally buffered
+# We can't calculate the equilibrium activity of a basis species if it's externally buffered
 expect_error(diagram(a, "O2"), "is not numeric - was a buffer selected\\?", info = info)
-# this one works - a barplot of A/2.303RT
+# This one works - a barplot of A/2.303RT
 expect_message(diagram(a, plot.it = FALSE), "balance: on moles of CO2 in formation reactions", info = info)
-# if we're plotting A/2.303RT the values can be divided by balancing coefficient or not
+# If we're plotting A/2.303RT the values can be divided by balancing coefficient or not
 d.1 <- diagram(a, balance = 1, plot.it = FALSE)
 d.CO2 <- diagram(a, plot.it = FALSE)
 expect_equal(as.numeric(d.CO2$plotvals), as.numeric(d.1$plotvals)/c(1, 1, 2, 2), info = info)
-# now run the calculation over a range of O2 
+# Now run the calculation over a range of O2 
 basis("O2", -90)
 # 1-D
 a <- affinity(O2 = c(-80, -70))
-# ask for the equilibrium activity of CO2
+# Ask for the equilibrium activity of CO2
 expect_error(diagram(a, "CO2", groups = list(1:2, 3:4)), "can't plot equilibrium activities of basis species for grouped species", info = info)
 expect_error(diagram(a, "CO2", alpha = TRUE), "equilibrium activities of basis species not available with alpha = TRUE", info = info)
 d <- diagram(a, "CO2", plot.it = FALSE)
-# test that the result does in fact correspond to zero affinity of formation, how about for acetate?
+# Test that the result does in fact correspond to zero affinity of formation, how about for acetate?
 a <- affinity(O2 = d$vals[[1]], CO2 = d$plotvals[[4]])
 expect_equal(a$values[[4]], array(numeric(256)), info = info)
 
@@ -45,15 +45,15 @@
 # 1-D
 a <- affinity(O2 = c(-80, -60))
 e <- equilibrate(a)
-# group the species together
+# Group the species together
 d <- diagram(e, groups = list(1:2, 3:4), plot.it = FALSE)
-# we should find that their activities have been multiplied by the balance coefficients and summed
+# We should find that their activities have been multiplied by the balance coefficients and summed
 n.balance <- CHNOSZ:::balance(a)$n.balance
 expect_equal(d$plotvals[[1]], log10(n.balance[1]*10^e$loga.equil[[1]] + n.balance[2]*10^e$loga.equil[[2]]), info = info)
 expect_equal(d$plotvals[[2]], log10(n.balance[3]*10^e$loga.equil[[3]] + n.balance[4]*10^e$loga.equil[[4]]), info = info)
-# ask for degrees of formation instead of logarithms of activities
+# Ask for degrees of formation instead of logarithms of activities
 d <- diagram(e, alpha = TRUE, plot.it = FALSE)
-# we should find that the sum of alphas is one
+# We should find that the sum of alphas is one
 expect_equal(Reduce("+", d$plotvals), array(rep(1, 256)), check.attributes = FALSE, info = info)
 
 info <- "'normalize' and 'as.residue' work as expected"
@@ -75,7 +75,7 @@
 expect_equal(d3$predominant, d4$predominant, info = info)
 
 info <- "NaN values from equilibrate() are preserved (as NA in predominance calculation)"
-# example provided by Grayson Boyer 20170411
+# Example provided by Grayson Boyer 20170411
 basis(c("H2", "O2", "CO2"), c(-7.19, -60, -2.65))
 species(c("n-hexadecanol", "n-hexadecanoic acid", "n-octadecanol", "n-octadecanoic acid"), c("liq", "liq", "liq", "liq"))
 a <- affinity("H2" = c(-12, 0), "O2" = c(-90, -50), T = 30)
@@ -86,7 +86,7 @@
 expect_equal(d$predominant[1, 256], as.numeric(NA), info = info)
 expect_equal(d$predominant[256, 1], as.numeric(NA), info = info)
 
-## add the test but exclude it for now because plot.it = FALSE doesn't produce values for namesx 20190223
+## TODO: Exclude this test for now because plot.it = FALSE doesn't produce values for namesx 20190223
 #info <- "labels are dropped outside of xlim and ylim ranges"
 #basis(c("Fe", "O2", "S2"))
 #species(c("iron", "ferrous-oxide", "magnetite",
@@ -103,7 +103,7 @@
 #expect_equal(sum(is.na(d$namesx)), 2, info = info)
 
 info <- "P-T diagram has expected geometry"
-# modifified from kayanite-sillimanite-andalusite example in ?diagram 20200811
+# Modified from kayanite-sillimanite-andalusite example in ?diagram 20200811
 basis(c("corundum", "quartz", "oxygen"))
 species(c("kyanite", "sillimanite", "andalusite"))
 a <- affinity(T = c(200, 900, 50), P = c(0, 9000, 51), exceed.Ttr = TRUE)
@@ -113,7 +113,7 @@
 expect_equal(species()$name[d$predominant[50, 51]], "sillimanite", info = info)
 
 info <- "diagram(type = .) and affinity(return.buffer = TRUE) give the same results"
-# extracted from ?buffer 20200811
+# Extracted from ?buffer 20200811
 O2 <- c(-85, -70, 4)
 T <- c(25, 100, 4)
 basis("CHNOS")
@@ -123,7 +123,7 @@
 a <- affinity(O2 = O2, T = T)
 d <- diagram(a, type = "CO2", plot.it = FALSE)
 and <- as.numeric(d$plotvals[[1]])
-# now do the calculation with affinity(return.buffer = TRUE)
+# Now do the calculation with affinity(return.buffer = TRUE)
 basis("CO2", "AC")
 mod.buffer("AC", logact = -10)
 a.buffer <- affinity(O2 = O2, T = T, return.buffer = TRUE)

Modified: pkg/CHNOSZ/inst/tinytest/test-eos.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-eos.R	2023-02-20 01:50:55 UTC (rev 767)
+++ pkg/CHNOSZ/inst/tinytest/test-eos.R	2023-02-20 02:33:09 UTC (rev 768)
@@ -100,7 +100,7 @@
   mod.OBIGT(species[i], omega = 0)
   Vn2 <- c(Vn2, subcrt(species[i], T = 25)$out[[1]]$V)
 }
-expect_equal(Vn1, Vn2)
+expect_equal(Vn1, Vn2, info = info)
 
 # Reference
 

Modified: pkg/CHNOSZ/inst/tinytest/test-equilibrate.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-equilibrate.R	2023-02-20 01:50:55 UTC (rev 767)
+++ pkg/CHNOSZ/inst/tinytest/test-equilibrate.R	2023-02-20 02:33:09 UTC (rev 768)
@@ -1,23 +1,23 @@
 # Load default settings for CHNOSZ
 reset()
 
-# set up some simple systems
-# one acid
+# Set up some simple systems
+# One acid
 basis("CHNOS+")
 species("acetic acid")
 aone <- suppressMessages(affinity())
-# acids
+# Acids
 species(c("formic acid", "formate", "acetate"), add = TRUE)
 aacid <- suppressMessages(affinity())
-# acids plus a sulfur species
+# Acids plus a sulfur species
 species("H2S", add = TRUE)
 aacidS <- suppressMessages(affinity())
-# proteins
+# Proteins
 species(c("LYSC_CHICK", "MYG_PHYCA", "RNAS1_BOVIN", "CYC_BOVIN"))
 aprot <- suppressMessages(affinity())
 
 info <- "equilibrate() gives expected messages and errors for balance calculation"
-# the following error is triggered by equil.react, not equil.boltzmann
+# The following error is triggered by equil.react, not equil.boltzmann
 expect_error(equilibrate(aone), "at least two species needed", info = info)
 expect_message(equilibrate(aacid), "balance: on moles of CO2", info = info)
 expect_message(equilibrate(aacid), "n.balance is 2 1 1 2", info = info)
@@ -35,56 +35,56 @@
 expect_message(equilibrate(aprot, normalize = TRUE), "using 'normalize' for molar formulas", info = info)
 
 info <- "equilibrate() gives expected messages and errors for species selection"
-# an error if we select no species
+# An error if we select no species
 expect_error(equilibrate(aacid, ispecies = numeric()), "the length of ispecies is zero", info = info)
-# an error if all affinities are NA
+# An error if all affinities are NA
 aNA <- aacid
 aNA$values[1:2] <- NA
 expect_error(equilibrate(aNA, ispecies = 1:2), "all species have NA affinities", info = info)
-# a message if we select only certain of the species
+# A message if we select only certain of the species
 expect_message(equilibrate(aacid, ispecies = 1:2), "using 2 of 4 species", info = info)
 
 info <- "equilibrate() keeps the same total loga.balance for normalize = TRUE or FALSE"
-# use the proteins
+# Use the proteins
 e.norm <- equilibrate(aprot, normalize = TRUE)
 e <- equilibrate(aprot)
-# the total activity of the balance in the two cases
+# The total activity of the balance in the two cases
 sumact.balance.norm <- sum(10^unlist(e.norm$loga.equil)*e.norm$m.balance)
 sumact.balance <- sum(10^unlist(e$loga.equil)*e$n.balance)
 expect_equal(sumact.balance.norm, sumact.balance, info = info)
 
 info <- "equilibrate() reproduces an example from the literature"
-# the reference values are the equilibrium logarithms of activities
+# The reference values are the equilibrium logarithms of activities
 # of sulfur species at logfO2 = -30 from Seewald, 2001
-# we name them here because S5O6-2 isn't on the plot at logfO2 = -30, 
+# We name them here because S5O6-2 isn't on the plot at logfO2 = -30, 
 # and to get them in order
 species.ref <- c("S3O6-2", "S2O6-2", "S2O4-2", "S3-2", "S2-2", "S2O3-2", "HSO3-", "SO2", "HSO4-", "H2S")
-# these values were read from the plot using g3data
+# These values were read from the plot using g3data
 loga.ref <- c(-28.82, -24.70, -22.10, -14.19, -12.12, -11.86, -8.40, -7.40, -6.54, -1.95)
-# set up the system - see ?diagram for an example showing the entire plot
+# Set up the system - see ?diagram for an example showing the entire plot
 basis("CHNOS+")
 basis(c("pH", "O2"), c(5, -30))
-# we include here all the species shown by Seewald, 2001
+# We include here all the species shown by Seewald, 2001
 species(c("H2S", "S2-2", "S3-2", "S2O3-2", "S2O4-2", "S3O6-2", "S5O6-2", "S2O6-2", "HSO3-", "SO2", "HSO4-"))
 a <- affinity(T = 325, P = 350)
 # loga.balance = -2 signifies 10 mmolal total sulfur
 e <- equilibrate(a, loga.balance = -2)
-# get the calculated activities of the reference species
+# Get the calculated activities of the reference species
 loga.equil <- unlist(e$loga.equil[match(species.ref, e$species$name)])
-# the test... the tolerance may seem high, but consider that the reference values
+# The test... the tolerance may seem high, but consider that the reference values
 # were read from a plot with 30 logfO2 units spanning 4 inches
 expect_true(all(abs(loga.equil-loga.ref) < 0.36), info = info)
 
 info <- "equilibrate() can be used for huge values of Astar"
-## working out some bugs and testing new 'method' argument 20151109
+## Working out some bugs and testing new 'method' argument 20151109
 
-## first, demonstrate that equil.reaction works where equil.boltzmann doesn't
-# minimal example: Astar = c(0, 0), n.balance = c(1, 1), loga.balance = 0
+## First, demonstrate that equil.reaction works where equil.boltzmann doesn't
+# Minimal example: Astar = c(0, 0), n.balance = c(1, 1), loga.balance = 0
 # results in equal activities of two species
 eb0 <- equil.boltzmann(c(0, 0), c(1, 1), 0)
 expect_equal(unlist(eb0), rep(log10(0.5), 2), info = info)
 # Astar = c(-330, -330)
-# result is NaN (we probably get an Inf-Inf somewhere)
+# Result is NaN (we probably get an Inf-Inf somewhere)
 eb330 <- equil.boltzmann(c(-330, -330), c(1, 1), 0)
 expect_equal(unlist(eb330), rep(NaN, 2), info = info)
 # (fixed bug: while loop in equil.reaction tested a NaN value)
@@ -92,7 +92,7 @@
 er330 <- equil.reaction(c(-330, -330), c(1, 1), 0)
 expect_equal(er330, eb0, info = info)
 
-## second, set up extreme test case and show boltzmann method produces NaN (is.na)
+## Second, set up extreme test case and show boltzmann method produces NaN (is.na)
 basis("CHNOS")
 basis("O2", 200)
 species(c("glycine", "alanine", "proline"))
@@ -100,15 +100,15 @@
 expect_message(eb <- equilibrate(a, balance = 1), "using boltzmann method", info = info)
 expect_true(all(is.na(unlist(eb$loga.equil))), info = info)
 
-## third, check we can use method = "reaction"
+## Third, check we can use method = "reaction"
 expect_message(er1 <- equilibrate(a, balance = 1, method = "reaction"), "using reaction method", info = info)
 expect_false(any(is.na(unlist(er1$loga.equil))), info = info)
-# is it an equilibrium solution?
+# Is it an equilibrium solution?
 species(1:3, unlist(er1$loga.equil))
 a1 <- affinity()
 expect_equal(diff(range(unlist(a1$values))), 0, info = info)
 
-## third, check that we can use arbitrary numeric balance specification
+## Fourth, check that we can use arbitrary numeric balance specification
 # (balance <> 1 here means equilibrate will call equil.reaction)
 expect_message(er11 <- equilibrate(a, balance = 1.000001), "using reaction method", info = info)
 species(1:3, unlist(er11$loga.equil))
@@ -115,37 +115,37 @@
 a11 <- affinity()
 expect_equal(unlist(a1$values), unlist(a11$values), info = info)
 
-## fourth, check that equil.boltzmann won't run for balance <> 1
+## Fifth, check that equil.boltzmann won't run for balance <> 1
 expect_error(equilibrate(a, balance = 1.000001, method = "boltzmann"), "won't run equil.boltzmann", info = info)
 
 info <- "equilibrate() can be used with a vector of loga.balance values"
-# system is balanced on CO2; species have different number of C, so loga.balance affects the equilibrium activities
+# System is balanced on CO2; species have different number of C, so loga.balance affects the equilibrium activities
 basis("CHNOS")
 species(c("formic acid", "acetic acid", "propanoic acid"))
-# calculate reference values at logfO2 = -80, log(aCO2tot) = -6
+# Calculate reference values at logfO2 = -80, log(aCO2tot) = -6
 basis("O2", -80)
 a <- affinity()
 e80.6 <- unlist(equilibrate(a, loga.balance = -6)$loga.equil)
-# calculate reference values at logfO2 = -60, log(aCO2tot) = -8
+# Calculate reference values at logfO2 = -60, log(aCO2tot) = -8
 basis("O2", -60)
 a <- affinity()
 e60.8 <- unlist(equilibrate(a, loga.balance = -8)$loga.equil)
-# calculate affinity on a transect: logfO2 from -80 to -60
+# Calculate affinity on a transect: logfO2 from -80 to -60
 O2 <- seq(-80, -60)
 aO2 <- affinity(O2 = O2)
-# values calculated at the ends of the transect should be the same as above
+# Values calculated at the ends of the transect should be the same as above
 eO2.6 <- equilibrate(aO2, loga.balance = -6)$loga.equil
 expect_equal(list2array(eO2.6)[1, ], e80.6, info = info)
 eO2.8 <- equilibrate(aO2, loga.balance = -8)$loga.equil
 expect_equal(list2array(eO2.8)[21, ], e60.8, info = info)
-# make an vector of loga.balance to go with the logfO2 transect
-# first we make a vector with non-matching length, and get an error
+# Make an vector of loga.balance to go with the logfO2 transect
+# First we make a vector with non-matching length, and get an error
 logaCO2.wronglen <- seq(-6, -8)
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/chnosz -r 768


More information about the CHNOSZ-commits mailing list