[Zooimage-commits] r246 - pkg/zooimage/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Mar 2 09:33:45 CET 2014


Author: phgrosjean
Date: 2014-03-02 09:33:44 +0100 (Sun, 02 Mar 2014)
New Revision: 246

Modified:
   pkg/zooimage/R/ZIClass.R
   pkg/zooimage/R/correction.R
   pkg/zooimage/R/fileutils.R
   pkg/zooimage/R/planktonSorter.R
Log:
Internal refactoring of code: namespace calls

Modified: pkg/zooimage/R/ZIClass.R
===================================================================
--- pkg/zooimage/R/ZIClass.R	2014-03-02 07:52:45 UTC (rev 245)
+++ pkg/zooimage/R/ZIClass.R	2014-03-02 08:33:44 UTC (rev 246)
@@ -200,10 +200,10 @@
 	
 	## Construct the confusion object
 	if (missing(prior)) {
-		mlearning:::.confusion(data.frame(class1 = y, class2 = class2),
-			labels = labels, useNA = useNA, ...)
+		getNamespace("mlearning")$.confusion(data.frame(class1 = y,
+			class2 = class2), labels = labels, useNA = useNA, ...)
 	} else {
-		mlearning:::.confusion(data.frame(class1 = y, class2 = class2),
-			labels = labels, useNA = useNA, prior = prior, ...)
+		getNamespace("mlearning")$.confusion(data.frame(class1 = y,
+			class2 = class2), labels = labels, useNA = useNA, prior = prior, ...)
 	}
 }

Modified: pkg/zooimage/R/correction.R
===================================================================
--- pkg/zooimage/R/correction.R	2014-03-02 07:52:45 UTC (rev 245)
+++ pkg/zooimage/R/correction.R	2014-03-02 08:33:44 UTC (rev 246)
@@ -450,7 +450,7 @@
 		if (mode != "stat") {
 			if (is.null(testdir))
 				testdir <<- file.path(tempdir(),
-					zooimage::noExtension(zidb))
+					noExtension(zidb))
 			if (file.exists(testdir)) {
 				
 				res <- dlgMessage(paste("Temporary validation directory already",
@@ -727,7 +727,7 @@
 ## TODO: change this!
 #			## Read Test set with getTest() from zooimage package
 #			SubDir <- file.path(testdir, paste0("step", step))
-#			TestSetStep <- zooimage::getTest(SubDir)[, c("Id", "Class")]
+#			TestSetStep <- getTest(SubDir)[, c("Id", "Class")]
 			## Id if items validated at step 'i' and included in data
 ## ????
 #			dfId <- data.frame(Id = as.factor(rownames(data))[corr$Step == step])

Modified: pkg/zooimage/R/fileutils.R
===================================================================
--- pkg/zooimage/R/fileutils.R	2014-03-02 07:52:45 UTC (rev 245)
+++ pkg/zooimage/R/fileutils.R	2014-03-02 08:33:44 UTC (rev 246)
@@ -150,3 +150,28 @@
 	if (!res) warning(sprintf(message, file))
 	return(res) 
 }
+
+## This is a copy of the unexporter function tools:::mime_canonical_encoding
+.mimeEncoding <- function (encoding) 
+{
+    encoding[encoding %in% c("", "unknown")] <- utils::localeToCharset()[1L]
+    encoding <- tolower(encoding)
+    encoding <- sub("iso_8859-([0-9]+)", "iso-8859-\\1", encoding)
+    encoding <- sub("iso8859-([0-9]+)", "iso-8859-\\1", encoding)
+    encoding[encoding == "latin1"] <- "iso-8859-1"
+    encoding[encoding == "latin2"] <- "iso-8859-2"
+    encoding[encoding == "latin3"] <- "iso-8859-3"
+    encoding[encoding == "latin4"] <- "iso-8859-4"
+    encoding[encoding == "cyrillic"] <- "iso-8859-5"
+    encoding[encoding == "arabic"] <- "iso-8859-6"
+    encoding[encoding == "greek"] <- "iso-8859-7"
+    encoding[encoding == "hebrew"] <- "iso-8859-8"
+    encoding[encoding == "latin5"] <- "iso-8859-9"
+    encoding[encoding == "latin6"] <- "iso-8859-10"
+    encoding[encoding == "latin8"] <- "iso-8859-14"
+    encoding[encoding == "latin-9"] <- "iso-8859-15"
+    encoding[encoding == "latin10"] <- "iso-8859-16"
+    encoding[encoding == "utf8"] <- "utf-8"
+    encoding[encoding == "ascii"] <- "us-ascii"
+    encoding
+}

Modified: pkg/zooimage/R/planktonSorter.R
===================================================================
--- pkg/zooimage/R/planktonSorter.R	2014-03-02 07:52:45 UTC (rev 245)
+++ pkg/zooimage/R/planktonSorter.R	2014-03-02 08:33:44 UTC (rev 246)
@@ -31,7 +31,7 @@
 <head>'
     html <- c(html, sprintf("<title>%s</title>", title))
     html <- c(html, sprintf('<meta http-equiv="Content-Type" content="text/html; charset=%s">',
-		tools:::mime_canonical_encoding("UTF-8"))) 
+		.mimeEncoding("UTF-8"))) 
 	html <- c(html, sprintf(
 '	<script src="../planktonSorter/jquery-1.11.0.min.js"></script>
 	<link rel="stylesheet" type="text/css" href="../planktonSorter/planktonSorter.css">	
@@ -139,7 +139,7 @@
 <head>'
     html <- c(html, sprintf("<title>%s</title>", title))
     html <- c(html, sprintf('<meta http-equiv="Content-Type" content="text/html; charset=%s">',
-		tools:::mime_canonical_encoding("UTF-8"))) 
+		.mimeEncoding("UTF-8"))) 
 	html <- c(html, sprintf('	<meta http-equiv="cache-control" content="no-cache">
 	<link rel="stylesheet" type="text/css" href="../planktonSorter/planktonSorter.css">
 	<script language="javascript" type="text/javascript">



More information about the Zooimage-commits mailing list