+test_that("serialization + transform + getDataInFile retrieve original transforms",
+{
+ data_bin_file = "/tmp/epclust_test_t.bin"
+ unlink(data_bin_file)
+
+ #dataset 200 lignes / 30 columns
+ data_ascii = matrix(runif(200*30,-10,10),ncol=30)
+ nbytes = 8
+ endian = "little"
+
+ binarize(data_ascii, data_bin_file, 500, ",", nbytes, endian)
+ # Serialize transformation (just compute range) into a new binary file
+ trans_bin_file = "/tmp/epclust_test_t_trans.bin"
+ unlink(trans_bin_file)
+ getSeries = function(inds) getDataInFile(inds, data_bin_file, nbytes, endian)
+ binarizeTransform(getSeries, function(series) t(apply(series, 1, range)),
+ trans_bin_file, 250, nbytes, endian)
+ unlink(data_bin_file)
+ expect_equal(file.info(trans_bin_file)$size, 2*nrow(data_ascii)*nbytes+8)
+ for (indices in list(c(1,3,5), 3:13, c(5,20,50), c(75,130:135), 196:200))
+ {
+ trans_lines = getDataInFile(indices, trans_bin_file, nbytes, endian)
+ expect_equal(trans_lines, t(apply(data_ascii[indices,],1,range)), tolerance=1e-6)
+ }
+ unlink(trans_bin_file)
+})
+