[CHNOSZ-commits] r663 - in pkg/CHNOSZ: . R inst tests/testthat
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Mar 23 00:43:05 CET 2021
Author: jedick
Date: 2021-03-23 00:43:04 +0100 (Tue, 23 Mar 2021)
New Revision: 663
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/info.R
pkg/CHNOSZ/inst/TODO
pkg/CHNOSZ/tests/testthat/test-info.R
Log:
Improve messages output by info()
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2021-03-22 12:48:39 UTC (rev 662)
+++ pkg/CHNOSZ/DESCRIPTION 2021-03-22 23:43:04 UTC (rev 663)
@@ -1,6 +1,6 @@
-Date: 2021-03-21
+Date: 2021-03-22
Package: CHNOSZ
-Version: 1.4.0-32
+Version: 1.4.0-33
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/info.R
===================================================================
--- pkg/CHNOSZ/R/info.R 2021-03-22 12:48:39 UTC (rev 662)
+++ pkg/CHNOSZ/R/info.R 2021-03-22 23:43:04 UTC (rev 663)
@@ -144,12 +144,9 @@
mystate <- thermo$OBIGT$state[ispecies.out]
ispecies.other <- ispecies[!ispecies %in% ispecies.out]
otherstates <- thermo$OBIGT$state[ispecies.other]
- # for minerals (cr), use the word "phase"; otherwise, use "state" 20190209
- word <- "state"
- # substitute the mineral name for "cr" 20190121
- if(mystate == "cr" | sum(otherstates=="cr") > 1) {
- word <- "phase"
- otherstates[otherstates=="cr"] <- thermo$OBIGT$name[ispecies.other[otherstates=="cr"]]
+ # For non-aqueous species, list other substances (isomers) in the same state 20210321
+ if(mystate != "aq" & sum(otherstates==mystate) > 0) {
+ otherstates[otherstates==mystate] <- thermo$OBIGT$name[ispecies.other[otherstates==mystate]]
}
transtext <- othertext <- ""
# we count, but don't show the states for phase transitions (cr2, cr3, etc)
@@ -159,14 +156,19 @@
ntrans <- sum(istrans)
if(ntrans == 1) transtext <- paste(" with", ntrans, "phase transition")
else if(ntrans > 1) transtext <- paste(" with", ntrans, "phase transitions")
- # if it's not already in the species name, substitute the mineral name for "cr" 20190121
- if(species != thermo$OBIGT$name[ispecies.out]) mystate <- thermo$OBIGT$name[ispecies.out]
}
- otherstates <- otherstates[!istrans]
- if(length(otherstates) == 1) othertext <- paste0("; other available ", word, " is ", otherstates)
- if(length(otherstates) > 1) othertext <- paste0("; other available ", word, "s are ", paste(otherstates, collapse=", "))
+ myname <- NULL
+ if(mystate != "aq") {
+ # If it's not already in the species name, append the substance name 20210323
+ myname <- thermo$OBIGT$name[ispecies.out]
+ if(species == myname) myname <- NULL
+ }
+ otherstates <- unique(otherstates[!istrans])
+ if(length(otherstates) == 1) othertext <- paste0("; also available in ", otherstates)
+ if(length(otherstates) > 1) othertext <- paste0("; also available in ", paste(otherstates, collapse=", "))
if(transtext != "" | othertext != "") {
starttext <- paste0("info.character: found ", species, "(", mystate, ")")
+ if(!is.null(myname)) starttext <- paste0(starttext, " [", myname, "]")
message(starttext, transtext, othertext)
}
}
Modified: pkg/CHNOSZ/inst/TODO
===================================================================
--- pkg/CHNOSZ/inst/TODO 2021-03-22 12:48:39 UTC (rev 662)
+++ pkg/CHNOSZ/inst/TODO 2021-03-22 23:43:04 UTC (rev 663)
@@ -37,13 +37,6 @@
a2 <- affinity(iprotein = 1)
expect_equal(a1$values, a2$values)
-[20210122] Fix incorrect states in messages:
-> subcrt("C10H22")
-info.character: found C10H22(decane); other available phases are gas, gas, gas, liq, liq, liq
-> subcrt("C10H22", "liq")
-info.character: found C10H22(liq); other available states are liq, liq
-
-
[20210212]
- Fix formatting of messages from palply() (seen with read.fasta())
Modified: pkg/CHNOSZ/tests/testthat/test-info.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-info.R 2021-03-22 12:48:39 UTC (rev 662)
+++ pkg/CHNOSZ/tests/testthat/test-info.R 2021-03-22 23:43:04 UTC (rev 663)
@@ -4,8 +4,8 @@
expect_equal(info.character("acetate", "cr"), NA)
expect_message(info.character("acetate", "cr"), "only 'aq' is available")
expect_message(info.character("methane", "cr"), "only 'gas' 'liq' are available")
- expect_message(info.character("methane"), "other available state is liq")
- expect_message(info.character("SiO2", "cr"), "other available phases are")
+ expect_message(info.character("methane"), "also available in liq")
+ expect_message(info.character("SiO2", "cr"), "also available in.*quartz")
expect_message(info.character("chalcocite"), "found chalcocite\\(cr\\) with 2 phase transitions")
# H2O is a special case
expect_equal(info.character("H2O", "aq"), info.character("H2O", "liq"))
More information about the CHNOSZ-commits
mailing list