[CHNOSZ-commits] r188 - in pkg/CHNOSZ: . R inst man tests/testthat
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Apr 27 04:30:52 CEST 2017
Author: jedick
Date: 2017-04-27 04:30:51 +0200 (Thu, 27 Apr 2017)
New Revision: 188
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/diagram.R
pkg/CHNOSZ/inst/NEWS
pkg/CHNOSZ/man/diagram.Rd
pkg/CHNOSZ/tests/testthat/test-diagram.R
Log:
diagram(): add 'col.NA' argument
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2017-04-25 11:19:56 UTC (rev 187)
+++ pkg/CHNOSZ/DESCRIPTION 2017-04-27 02:30:51 UTC (rev 188)
@@ -1,6 +1,6 @@
-Date: 2017-04-25
+Date: 2017-04-27
Package: CHNOSZ
-Version: 1.0.8-76
+Version: 1.0.8-77
Title: Chemical Thermodynamics and Activity Diagrams
Author: Jeffrey Dick
Maintainer: Jeffrey Dick <j3ffdick at gmail.com>
Modified: pkg/CHNOSZ/R/diagram.R
===================================================================
--- pkg/CHNOSZ/R/diagram.R 2017-04-25 11:19:56 UTC (rev 187)
+++ pkg/CHNOSZ/R/diagram.R 2017-04-27 02:30:51 UTC (rev 188)
@@ -20,7 +20,7 @@
# line styles
lty=NULL, lwd=par("lwd"), dotted=NULL,
# colors
- col=par("col"), col.names=par("col"), fill=NULL,
+ col=par("col"), col.names=par("col"), fill=NULL, col.NA="black",
# labels
names=NULL, main=NULL, legend.x=NA, format.names=TRUE, adj=0.5, dy=0,
# plotting controls
@@ -315,8 +315,10 @@
zs <- out
for(i in 1:nrow(zs)) zs[i,] <- out[nrow(zs)+1-i,]
zs <- t(zs)
- breaks <- c(0,1:nspecies) + 0.5
- image(x=xs, y=ys, z=zs, col=fill, add=TRUE, breaks=breaks, useRaster=TRUE)
+ breaks <- c(-1, 0, 1:nspecies) + 0.5
+ # use col.NA for NA values
+ zs[is.na(zs)] <- 0
+ image(x=xs, y=ys, z=zs, col=c(col.NA, fill), add=TRUE, breaks=breaks, useRaster=TRUE)
}
## curve plot function
# 20091116 replaced plot.curve with plot.line; different
Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS 2017-04-25 11:19:56 UTC (rev 187)
+++ pkg/CHNOSZ/inst/NEWS 2017-04-27 02:30:51 UTC (rev 188)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.0.8-76 (2017-04-25)
+CHANGES IN CHNOSZ 1.0.8-77 (2017-04-27)
---------------------------------------
DOCUMENTATION:
@@ -161,8 +161,8 @@
the bug report and test.
- NaN values from equilibrate() are now preserved by diagram(),
- producing unlabeled blank (white) fields rather than being
- mistakenly labeled with the first species.
+ producing unlabeled fields rather than being mistakenly labeled with
+ the first species. Thanks to Grayson Boyer for the bug report.
OTHER CHANGES:
Modified: pkg/CHNOSZ/man/diagram.Rd
===================================================================
--- pkg/CHNOSZ/man/diagram.Rd 2017-04-25 11:19:56 UTC (rev 187)
+++ pkg/CHNOSZ/man/diagram.Rd 2017-04-27 02:30:51 UTC (rev 188)
@@ -14,7 +14,7 @@
ylog=TRUE, xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL,
cex=par("cex"), cex.names=1, cex.axis=par("cex"),
lty=NULL, lwd=par("lwd"), dotted=NULL,
- col=par("col"), col.names=par("col"), fill=NULL,
+ col=par("col"), col.names=par("col"), fill=NULL, col.NA="black",
names=NULL, main=NULL, legend.x=NA, format.names=TRUE, adj=0.5, dy=0,
add=FALSE, plot.it=TRUE, tplot=TRUE, ...)
strip(affinity, ispecies = NULL, col = NULL, ns = NULL,
@@ -48,6 +48,7 @@
\item{col}{character, color of activity lines (1D diagram) or predominance field boundaries (2D diagram), or colors of bars in a strip diagram (\code{strip})}
\item{col.names}{character, colors for labels of species}
\item{fill}{character, colors used to fill predominance fields}
+ \item{col.NA}{character, color for grid points with NA values}
\item{names}{character, names of species for activity lines or predominance fields}
\item{main}{character, a main \code{\link{title}} for the plot; \code{NULL} means to plot no title}
\item{legend.x}{character, description of legend placement passed to \code{\link{legend}}}
Modified: pkg/CHNOSZ/tests/testthat/test-diagram.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-diagram.R 2017-04-25 11:19:56 UTC (rev 187)
+++ pkg/CHNOSZ/tests/testthat/test-diagram.R 2017-04-27 02:30:51 UTC (rev 188)
@@ -85,3 +85,16 @@
#expect_equal(diagram(a), diagram(a, plot.it=FALSE))
expect_warning(diagram(a, what="CO2", plot.it=FALSE), "showing only first species in 2-D property diagram")
})
+
+test_that("NaN values from equilibrate() are preserved (as NA in predominance calculation)", {
+ # 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)
+ e <- equilibrate(a, balance = 1)
+ d <- diagram(e, plot.it = FALSE)
+ # equilibrate() here with default "boltzmann" method produces
+ # NaN at very high O2 + low H2 or very low O2 + high H2
+ expect_equal(d$predominant[1, 128], as.numeric(NA))
+ expect_equal(d$predominant[128, 1], as.numeric(NA))
+})
More information about the CHNOSZ-commits
mailing list