[CHNOSZ-commits] r373 - in pkg/CHNOSZ: . R inst tests/testthat

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 27 07:23:34 CET 2019


Author: jedick
Date: 2019-01-27 07:23:19 +0100 (Sun, 27 Jan 2019)
New Revision: 373

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/info.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/tests/testthat/test-info.R
Log:
info(): search for species in optional data files (SUPCRTBL, SUPCRT92)


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2019-01-27 05:50:10 UTC (rev 372)
+++ pkg/CHNOSZ/DESCRIPTION	2019-01-27 06:23:19 UTC (rev 373)
@@ -1,6 +1,6 @@
 Date: 2019-01-27
 Package: CHNOSZ
-Version: 1.1.3-80
+Version: 1.1.3-81
 Title: Thermodynamic Calculations and Diagrams for Geo(bio)chemistry
 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	2019-01-27 05:50:10 UTC (rev 372)
+++ pkg/CHNOSZ/R/info.R	2019-01-27 06:23:19 UTC (rev 373)
@@ -242,6 +242,14 @@
     return(approx.species)
   }
   # if we got here there were no approximate matches
+  # 20190127 look for the species in optional data files 
+  for(opt in c("SUPCRTBL", "SUPCRT92")) {
+    optdat <- read.csv(system.file(paste0("extdata/OBIGT/", opt, ".csv"), package="CHNOSZ"), as.is=TRUE)
+    if(species %in% optdat$name) {
+      message('info.approx: ', species, ' is in an optional database; use add.obigt("', opt, '", "', species, '") to load it')
+      return(NA)
+    }
+  }
   message("info.approx: '", species, "' has no approximate matches")
   return(NA)
 }

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2019-01-27 05:50:10 UTC (rev 372)
+++ pkg/CHNOSZ/inst/NEWS	2019-01-27 06:23:19 UTC (rev 373)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.1.3-80 (2019-01-27)
+CHANGES IN CHNOSZ 1.1.3-81 (2019-01-27)
 ---------------------------------------
 
 BUG FIXES
@@ -215,6 +215,9 @@
 - info(): display mineral names instead of just "cr" in messages (e.g.
   for info("SiO2")).
 
+- info(): species with no matches in default database are also
+  searched in optional data files (SUPCRTBL, SUPCRT92).
+
 - Add C implementation of counting occurrences of all letters in a
   string (src/count_letters.c) to speed up operation of count.aa().
 

Modified: pkg/CHNOSZ/tests/testthat/test-info.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-info.R	2019-01-27 05:50:10 UTC (rev 372)
+++ pkg/CHNOSZ/tests/testthat/test-info.R	2019-01-27 06:23:19 UTC (rev 373)
@@ -20,8 +20,10 @@
 test_that("info.approx() produces expected messages", {
   expect_message(info.approx("lactic"), "is similar to lactic acid")
   expect_message(info.approx("lactic acid"), "is ambiguous")
-  # note though that info("lactic acid") finds a match b/c info.character is used first...
+  # note though that info("lactic acid") finds a match because info.character is used first...
   expect_equal(info("lactic acid"), grep("lactic acid", thermo$obigt$name))
+  # looking in optional databases 20190127
+  expect_message(info("gibbsite"), "is in an optional database")
 })
 
 test_that("info() can be used for cr and aq descriptions of the same species and proteins", {



More information about the CHNOSZ-commits mailing list