[CHNOSZ-commits] r517 - in pkg/CHNOSZ: . R inst tests/testthat
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Dec 5 02:29:39 CET 2019
Author: jedick
Date: 2019-12-05 02:29:39 +0100 (Thu, 05 Dec 2019)
New Revision: 517
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/add.obigt.R
pkg/CHNOSZ/R/basis.R
pkg/CHNOSZ/R/objective.R
pkg/CHNOSZ/R/util.args.R
pkg/CHNOSZ/R/util.blast.R
pkg/CHNOSZ/R/util.expression.R
pkg/CHNOSZ/R/util.fasta.R
pkg/CHNOSZ/R/util.matrix.R
pkg/CHNOSZ/inst/NEWS
pkg/CHNOSZ/tests/testthat/test-revisit.R
Log:
change class() to inherits() (fix for R-devel)
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2019-11-16 03:14:04 UTC (rev 516)
+++ pkg/CHNOSZ/DESCRIPTION 2019-12-05 01:29:39 UTC (rev 517)
@@ -1,6 +1,6 @@
-Date: 2019-11-16
+Date: 2019-12-05
Package: CHNOSZ
-Version: 1.3.3-13
+Version: 1.3.3-14
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/add.obigt.R
===================================================================
--- pkg/CHNOSZ/R/add.obigt.R 2019-11-16 03:14:04 UTC (rev 516)
+++ pkg/CHNOSZ/R/add.obigt.R 2019-12-05 01:29:39 UTC (rev 517)
@@ -145,7 +145,7 @@
id2 <- paste(to2$name,to2$state)
# check if the data is compatible with thermo$obigt
tr <- try(rbind(to1,to2),silent=TRUE)
- if(identical(class(tr),'try-error')) stop(paste(file,"is not compatible with thermo$obigt data table."))
+ if(inherits(tr, "try-error")) stop(paste(file, "is not compatible with thermo$obigt data table."))
# match the new species to existing ones
does.exist <- id2 %in% id1
ispecies.exist <- na.omit(match(id2, id1))
Modified: pkg/CHNOSZ/R/basis.R
===================================================================
--- pkg/CHNOSZ/R/basis.R 2019-11-16 03:14:04 UTC (rev 516)
+++ pkg/CHNOSZ/R/basis.R 2019-12-05 01:29:39 UTC (rev 517)
@@ -118,7 +118,7 @@
else stop("the number of basis species is less than the number of elements")
}
# the second test: matrix is invertible
- if(class(try(solve(comp), silent=TRUE))=='try-error')
+ if(inherits(try(solve(comp), silent=TRUE), "try-error"))
stop("singular stoichiometric matrix")
# store the basis definition in thermo$basis, including
# both numeric and character data, so we need to use a data frame
Modified: pkg/CHNOSZ/R/objective.R
===================================================================
--- pkg/CHNOSZ/R/objective.R 2019-11-16 03:14:04 UTC (rev 516)
+++ pkg/CHNOSZ/R/objective.R 2019-12-05 01:29:39 UTC (rev 517)
@@ -54,7 +54,7 @@
qqrfun <- function(x) {
# this is to catch errors from qqnorm
qqn <- try(qqnorm(x, plot.it=FALSE), silent=TRUE)
- if(class(qqn)=="try-error") qqr <- NA
+ if(inherits(qqn, "try-error")) qqr <- NA
else qqr <- cor(qqn[[1]], qqn[[2]])
}
# apply the function to the rows of loga1
Modified: pkg/CHNOSZ/R/util.args.R
===================================================================
--- pkg/CHNOSZ/R/util.args.R 2019-11-16 03:14:04 UTC (rev 516)
+++ pkg/CHNOSZ/R/util.args.R 2019-12-05 01:29:39 UTC (rev 517)
@@ -46,7 +46,7 @@
# 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(class(name)=="try-error") name <- character()
+ if(inherits(name, "try-error")) name <- character()
}
return(name)
}
Modified: pkg/CHNOSZ/R/util.blast.R
===================================================================
--- pkg/CHNOSZ/R/util.blast.R 2019-11-16 03:14:04 UTC (rev 516)
+++ pkg/CHNOSZ/R/util.blast.R 2019-12-05 01:29:39 UTC (rev 517)
@@ -6,7 +6,7 @@
## E-value and max hits per query
read.blast <- function(file, similarity=30, evalue=1e-5, max.hits=1, min.length=NA, quiet=FALSE) {
# display some information about the file
- if("connection" %in% class(file)) fname <- summary(file)$description
+ if(inherits(file, "connection")) fname <- summary(file)$description
else fname <- basename(file)
cat(paste("read.blast: reading", fname, "\n"))
# read the blast tabular file
Modified: pkg/CHNOSZ/R/util.expression.R
===================================================================
--- pkg/CHNOSZ/R/util.expression.R 2019-11-16 03:14:04 UTC (rev 516)
+++ pkg/CHNOSZ/R/util.expression.R 2019-12-05 01:29:39 UTC (rev 517)
@@ -19,7 +19,7 @@
elements <- suppressWarnings(try(makeup(species), TRUE))
} else elements <- split.formula(species)
# if species can't be parsed as a chemical formula, we don't do the formula formatting
- if(identical(class(elements), "try-error") | !is.numeric(elements)) expr <- species
+ if(inherits(elements, "try-error") | !is.numeric(elements)) expr <- species
else {
# where we'll put the expression
expr <- ""
Modified: pkg/CHNOSZ/R/util.fasta.R
===================================================================
--- pkg/CHNOSZ/R/util.fasta.R 2019-11-16 03:14:04 UTC (rev 516)
+++ pkg/CHNOSZ/R/util.fasta.R 2019-12-05 01:29:39 UTC (rev 517)
@@ -16,7 +16,7 @@
# otherwise ID is parsed from FASTA header (can take a while)
# check if the file is in an archive (https://github.com/jimhester/archive)
- if("archive_read" %in% class(file)) {
+ if(inherits(file, "archive_read")) {
is.archive <- TRUE
filebase <- gsub("]", "", basename(summary(file)$description))
} else {
@@ -115,7 +115,7 @@
oldopt <- options(warn=-1)
URLstuff <- try(readLines(proteinURL),TRUE)
options(oldopt)
- if(class(URLstuff)=="try-error") {
+ if(inherits(URLstuff, "try-error")) {
message(" ::: FAILED :::")
return(NA)
}
Modified: pkg/CHNOSZ/R/util.matrix.R
===================================================================
--- pkg/CHNOSZ/R/util.matrix.R 2019-11-16 03:14:04 UTC (rev 516)
+++ pkg/CHNOSZ/R/util.matrix.R 2019-12-05 01:29:39 UTC (rev 517)
@@ -15,7 +15,7 @@
for(i in 1:nrow(combs)) {
# a slow method, actually calculating the inverse
#tt <- try(solve(A[combs[i,],]),silent=TRUE)
- #if(class(tt)!="try-error") ic <- c(ic,i)
+ #if(!inherits(tt, "try-error")) ic <- c(ic,i)
# it's faster just to test if the determinant is non-zero
d <- det(A[combs[i,],])
if(abs(d) > zero) ic <- c(ic, i)
Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS 2019-11-16 03:14:04 UTC (rev 516)
+++ pkg/CHNOSZ/inst/NEWS 2019-12-05 01:29:39 UTC (rev 517)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.3.3-12 (2019-11-11)
+CHANGES IN CHNOSZ 1.3.3-14 (2019-12-05)
---------------------------------------
- describe.reaction(): remove the Unicode double arrow. A simple equals
@@ -42,6 +42,13 @@
to -999, and vice versa. Thanks to Feng Lai for the request and test
case.
+- Fix a bug where berman() returned NA values for K-feldspar below
+ 298.15 K, due to improperly initialized values for the disorder
+ properties. Thanks to Kaustubh Hakim for the bug report.
+
+- Use inherits() instead of class() for checking try() errors (don't
+ use conditions of length > 1 in if() statements -- fix for R-devel).
+
CHANGES IN CHNOSZ 1.3.3 (2019-08-02)
------------------------------------
Modified: pkg/CHNOSZ/tests/testthat/test-revisit.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-revisit.R 2019-11-16 03:14:04 UTC (rev 516)
+++ pkg/CHNOSZ/tests/testthat/test-revisit.R 2019-12-05 01:29:39 UTC (rev 517)
@@ -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_equal(c(r0.qqr$H), tail(r1.qqr$H, 1))
+ expect_equivalent(c(r0.qqr$H), 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_equal(head(r1.spearman$H, 1), -1) # perfect anti-rank correlation
+ expect_equivalent(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