[H5r-commits] r42 - R src tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 13 21:41:19 CEST 2011


Author: extemporaneousb
Date: 2011-04-13 21:41:18 +0200 (Wed, 13 Apr 2011)
New Revision: 42

Modified:
   R/h5R.R
   src/h5_wrap.c
   tests/testall.R
Log:
Added a test for the 1D read slab code.

Modified: R/h5R.R
===================================================================
--- R/h5R.R	2011-04-12 16:51:25 UTC (rev 41)
+++ R/h5R.R	2011-04-13 19:41:18 UTC (rev 42)
@@ -43,22 +43,6 @@
   length(x at s)
 })
 
-
-## setGeneric("start", function(x, ...) {
-##   standardGeneric("start")
-## })
-## setMethod("start", "hSlab", function(x) {
-##   x at s
-## })
-
-## setGeneric("width", function(x, ...) {
-##   standardGeneric("width")
-## })
-## setMethod("width", "hSlab", function(x) {
-##   x at w
-## })
-
-
 H5File <- function(fileName) {
   new("H5File", fileName)
 }

Modified: src/h5_wrap.c
===================================================================
--- src/h5_wrap.c	2011-04-12 16:51:25 UTC (rev 41)
+++ src/h5_wrap.c	2011-04-13 19:41:18 UTC (rev 42)
@@ -341,18 +341,23 @@
 
 SEXP h5R_read_1d_slabs(SEXP h5_dataset, SEXP _offsets, SEXP _counts) {
     int rlen = length(_counts);
-    SEXP r_lst; 
+    SEXP r_lst, _SEXP_offsets, _SEXP_counts;
     int i;
     int* counts = INTEGER(_counts);
     int* offsets = INTEGER(_offsets);
     
     PROTECT(r_lst = allocVector(VECSXP, rlen));
+    PROTECT(_SEXP_offsets = allocVector(INTSXP, 1));
+    PROTECT(_SEXP_counts  = allocVector(INTSXP, 1));
     
     for (i = 0; i < rlen; i++) {
-	SET_VECTOR_ELT(r_lst, i, h5R_read_slab(h5_dataset, ScalarInteger(offsets[i]), ScalarInteger(counts[i])));
+	INTEGER(_SEXP_offsets)[0] = offsets[i];
+	INTEGER(_SEXP_counts)[0] = counts[i];
+	SET_VECTOR_ELT(r_lst, i, h5R_read_slab(h5_dataset, _SEXP_offsets, 
+					       _SEXP_counts));
     }
+    UNPROTECT(3);
 
-    UNPROTECT(1);
     return(r_lst);
 }
 

Modified: tests/testall.R
===================================================================
--- tests/testall.R	2011-04-12 16:51:25 UTC (rev 41)
+++ tests/testall.R	2011-04-13 19:41:18 UTC (rev 42)
@@ -220,12 +220,16 @@
   }))
 })
 
+TH("slabs equal", all(readSlab(ds6, 1, 10) == read1DSlabs(ds6, 1, 10)[[1]]))
+TH("slabs equal iteration", {
+  r1 <- read1DSlabs(ds6, 1:10, rep(5, 10))
+  r2 <- lapply(1:10, function(a) {
+    as.integer(readSlab(ds6, a, 5))
+  })
+  all.equal(r1, r2)
+})
 
-dim(ds2)
 
-
-
-
 TH(action = "print")
 TH(action = "throw")
 



More information about the H5r-commits mailing list