Add XML documentation
This commit is contained in:
parent
64ec29196b
commit
428b95b3fb
@ -326,6 +326,9 @@ namespace MatFileHandler.Tests
|
||||
Assert.That(obj[2]["x"].ConvertToDoubleArray(), Is.EqualTo(new[] { -2.0 }));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test reading a table.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestTable()
|
||||
{
|
||||
|
@ -1,12 +1,21 @@
|
||||
using System;
|
||||
// Copyright 2017-2018 Alexander Luzgarev
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// A better interface for using table objects.
|
||||
/// </summary>
|
||||
public class TableAdapter
|
||||
{
|
||||
private readonly IMatObject matObject;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TableAdapter"/> class.
|
||||
/// </summary>
|
||||
/// <param name="array">Source table object.</param>
|
||||
public TableAdapter(IArray array)
|
||||
{
|
||||
matObject = array as IMatObject;
|
||||
@ -14,6 +23,7 @@ namespace MatFileHandler
|
||||
{
|
||||
throw new ArgumentException("The object provided is not a table.");
|
||||
}
|
||||
|
||||
var cellArray = matObject["varnames"] as ICellArray;
|
||||
VariableNames = Enumerable
|
||||
.Range(0, cellArray.Count)
|
||||
@ -22,7 +32,7 @@ namespace MatFileHandler
|
||||
NumberOfVariables = VariableNames.Length;
|
||||
var props = matObject["props"] as IStructureArray;
|
||||
Description = (props["Description"] as ICharArray).String;
|
||||
NumberOfRows = (int) matObject["nrows"].ConvertToDoubleArray()[0];
|
||||
NumberOfRows = (int)matObject["nrows"].ConvertToDoubleArray()[0];
|
||||
var rowNamesArrays = matObject["rownames"] as ICellArray;
|
||||
RowNames = Enumerable
|
||||
.Range(0, rowNamesArrays.Count)
|
||||
@ -30,14 +40,36 @@ namespace MatFileHandler
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets table description.
|
||||
/// </summary>
|
||||
public string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of rows in the table.
|
||||
/// </summary>
|
||||
public int NumberOfRows { get; }
|
||||
|
||||
public string[] RowNames { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of variables in the table.
|
||||
/// </summary>
|
||||
public int NumberOfVariables { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets row names.
|
||||
/// </summary>
|
||||
public string[] RowNames { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets variable names.
|
||||
/// </summary>
|
||||
public string[] VariableNames { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the data for a given variable
|
||||
/// </summary>
|
||||
/// <param name="variableName">Variable name.</param>
|
||||
/// <returns>All data associated with the variable.</returns>
|
||||
public IArray this[string variableName]
|
||||
{
|
||||
get
|
||||
@ -50,11 +82,10 @@ namespace MatFileHandler
|
||||
{
|
||||
throw new IndexOutOfRangeException($"Variable '{variableName}' not found.");
|
||||
}
|
||||
|
||||
var data = matObject["data"] as ICellArray;
|
||||
return data[index];
|
||||
}
|
||||
}
|
||||
|
||||
public string Description { get; }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user