public void ReadAllTest()
{
MemoryStream file = new MemoryStream(
Encoding.Default.GetBytes(Resources.iris_scale));
// Suppose we are going to read a sparse sample file containing
// samples which have an actual dimension of 4. Since the samples
// are in a sparse format, each entry in the file will probably
// have a much lesser number of elements.
int sampleSize = 4;
// Create a new Sparse Sample Reader to read any given file,
// passing the correct dense sample size in the constructor
SparseReader reader = new SparseReader(file, Encoding.Default, sampleSize);
// Declare a vector to obtain the label
// of each of the samples in the file
// Declare a vector to obtain the description (or comments)
// about each of the samples in the file, if present.
// Read the sparse samples and store them in a dense vector array
var r = reader.ReadDenseToEnd();
double[][] samples = r.Item1;
int[] labels = r.Item2.ToInt32();
string[] descriptions = reader.SampleDescriptions.ToArray();
Assert.AreEqual(150, samples.Length);
for (int i = 0; i < 150; i++)
{
Assert.IsTrue(labels[i] >= 0 && labels[i] <= 3);
Assert.IsTrue(descriptions[i] == String.Empty);
Assert.AreEqual(4, samples[i].Length);
}
}