[CHNOSZ-commits] r518 - in pkg/CHNOSZ: . R tests/testthat
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Dec 8 16:50:00 CET 2019
Author: jedick
Date: 2019-12-08 16:50:00 +0100 (Sun, 08 Dec 2019)
New Revision: 518
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/objective.R
pkg/CHNOSZ/R/util.args.R
pkg/CHNOSZ/tests/testthat/test-revisit.R
Log:
apply Martin Maechler's fixes for issues under R-devel
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2019-12-05 01:29:39 UTC (rev 517)
+++ pkg/CHNOSZ/DESCRIPTION 2019-12-08 15:50:00 UTC (rev 518)
@@ -1,6 +1,6 @@
Date: 2019-12-05
Package: CHNOSZ
-Version: 1.3.3-14
+Version: 1.3.3-15
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/R/objective.R
===================================================================
--- pkg/CHNOSZ/R/objective.R 2019-12-05 01:29:39 UTC (rev 517)
+++ pkg/CHNOSZ/R/objective.R 2019-12-08 15:50:00 UTC (rev 518)
@@ -53,9 +53,8 @@
# first, a function to calculate qqr
qqrfun <- function(x) {
# this is to catch errors from qqnorm
- qqn <- try(qqnorm(x, plot.it=FALSE), silent=TRUE)
- if(inherits(qqn, "try-error")) qqr <- NA
- else qqr <- cor(qqn[[1]], qqn[[2]])
+ qqn <- tryCatch(qqnorm(x, plot.it=FALSE), error=identity)
+ qqr <- if(inherits(qqn, "error")) NA else cor(qqn[[1]], qqn[[2]])
}
# apply the function to the rows of loga1
qqr <- apply(loga1, 1, qqrfun)
Modified: pkg/CHNOSZ/R/util.args.R
===================================================================
--- pkg/CHNOSZ/R/util.args.R 2019-12-05 01:29:39 UTC (rev 517)
+++ pkg/CHNOSZ/R/util.args.R 2019-12-08 15:50:00 UTC (rev 518)
@@ -42,11 +42,10 @@
if(sys.nframe() < n) name <- character()
else {
sc <- sys.call(-n)[[1]]
- name <- try(as.character(sc),silent=TRUE)
+ name <- tryCatch(as.character(sc), error = function(e) character())
# also return character() if the value from sys.call is
# the function itself (why does this sometimes happen,
# e.g. when called from affinity()?)
- if(inherits(name, "try-error")) name <- character()
}
return(name)
}
Modified: pkg/CHNOSZ/tests/testthat/test-revisit.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-revisit.R 2019-12-05 01:29:39 UTC (rev 517)
+++ pkg/CHNOSZ/tests/testthat/test-revisit.R 2019-12-08 15:50:00 UTC (rev 518)
@@ -37,7 +37,7 @@
r2.qqr <- revisit(e2, "qqr", plot.it=FALSE)
r3.qqr <- revisit(e3, "qqr", plot.it=FALSE)
# check that we get the same values
- expect_equivalent(c(r0.qqr$H), tail(r1.qqr$H, 1))
+ expect_equal(c(r0.qqr$H), c(tail(r1.qqr$H, 1)))
expect_equal(c(r0.qqr$H), r3.qqr$H[4, 3, 2])
# check that we get the same index and same optimum
expect_equal(r1.qqr$ixopt, r2.qqr$ixopt, check.attributes=FALSE)
@@ -62,7 +62,7 @@
# the referenced objectives compare the logarithms of activities (loga1) to reference values (loga2)
# the spearman correlation coefficient
r1.spearman <- revisit(e1, "spearman", c(1, 2, 3), plot.it=FALSE)
- expect_equivalent(head(r1.spearman$H, 1), -1) # perfect anti-rank correlation
+ expect_equal(c(head(r1.spearman$H, 1)), -1) # perfect anti-rank correlation
expect_equal(max(r1.spearman$H), 1) # perfect rank correlation
# where logarithm of activity of the 3rd species (glutamic acid) maximizes
r1.logact <- revisit(e1, "logact", 3, plot.it=FALSE)
More information about the CHNOSZ-commits
mailing list