Browse Source

Tests: embed test data as resource streams in new TestData project

pull/316/merge
Christoph Ruegg 11 years ago
parent
commit
771072142d
  1. 8
      MathNet.Numerics.All.sln
  2. 8
      MathNet.Numerics.Data.sln
  3. 8
      MathNet.Numerics.Net35Only.sln
  4. 8
      MathNet.Numerics.Portable.sln
  5. 8
      MathNet.Numerics.sln
  6. 353
      src/DataUnitTests/Matlab/MatlabReaderTests.cs
  7. 96
      src/DataUnitTests/Text/MatrixMarketReaderTests.cs
  8. 40
      src/DataUnitTests/UnitTests.csproj
  9. 5
      src/FSharpUnitTests/FSharpUnitTests-Net35.fsproj
  10. 5
      src/FSharpUnitTests/FSharpUnitTests-Portable47.fsproj
  11. 5
      src/FSharpUnitTests/FSharpUnitTests.fsproj
  12. 38
      src/TestData/Data.cs
  13. 36
      src/TestData/Properties/AssemblyInfo.cs
  14. 290
      src/TestData/TestData.csproj
  15. 6
      src/UnitTests/InterpolationTests/NevillePolynomialTest.cs
  16. 6
      src/UnitTests/StatisticsTests/CorrelationTests.cs
  17. 18
      src/UnitTests/StatisticsTests/DescriptiveStatisticsTests.cs
  18. 18
      src/UnitTests/StatisticsTests/RunningStatisticsTests.cs
  19. 8
      src/UnitTests/StatisticsTests/StatTestData.cs
  20. 21
      src/UnitTests/StatisticsTests/StatisticsTests.cs
  21. 4
      src/UnitTests/UnitTests-Net35.csproj
  22. 4
      src/UnitTests/UnitTests-Portable259.csproj
  23. 4
      src/UnitTests/UnitTests-Portable328.csproj
  24. 4
      src/UnitTests/UnitTests-Portable47.csproj
  25. 4
      src/UnitTests/UnitTests-Portable7.csproj
  26. 4
      src/UnitTests/UnitTests-Portable78.csproj
  27. 277
      src/UnitTests/UnitTests.csproj

8
MathNet.Numerics.All.sln

@ -73,6 +73,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests-Portable7", "src\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests-Portable78", "src\UnitTests\UnitTests-Portable78.csproj", "{2769BADC-02D9-48D9-88B4-C7E1C064BDF2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestData", "src\TestData\TestData.csproj", "{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -197,6 +199,12 @@ Global
{2769BADC-02D9-48D9-88B4-C7E1C064BDF2}.Release|Any CPU.Build.0 = Release|Any CPU
{2769BADC-02D9-48D9-88B4-C7E1C064BDF2}.Release-Signed|Any CPU.ActiveCfg = Release|Any CPU
{2769BADC-02D9-48D9-88B4-C7E1C064BDF2}.Release-Signed|Any CPU.Build.0 = Release|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release|Any CPU.Build.0 = Release|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release-Signed|Any CPU.ActiveCfg = Release|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release-Signed|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

8
MathNet.Numerics.Data.sln

@ -28,6 +28,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{D954831A
paket.lock = paket.lock
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestData", "src\TestData\TestData.csproj", "{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -53,6 +55,12 @@ Global
{9D3A08E1-6B96-4552-A535-412E589B3264}.Release|Any CPU.Build.0 = Release|Any CPU
{9D3A08E1-6B96-4552-A535-412E589B3264}.Release-Signed|Any CPU.ActiveCfg = Release|Any CPU
{9D3A08E1-6B96-4552-A535-412E589B3264}.Release-Signed|Any CPU.Build.0 = Release|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release|Any CPU.Build.0 = Release|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release-Signed|Any CPU.ActiveCfg = Release-Signed|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release-Signed|Any CPU.Build.0 = Release-Signed|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

8
MathNet.Numerics.Net35Only.sln

@ -18,6 +18,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp-Net35", "src\FSharp\
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpUnitTests-Net35", "src\FSharpUnitTests\FSharpUnitTests-Net35.fsproj", "{8C96F2E9-681B-4201-8BDD-0AA901203725}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestData", "src\TestData\TestData.csproj", "{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -49,6 +51,12 @@ Global
{8C96F2E9-681B-4201-8BDD-0AA901203725}.Release|Any CPU.Build.0 = Release|Any CPU
{8C96F2E9-681B-4201-8BDD-0AA901203725}.Release-Signed|Any CPU.ActiveCfg = Release-Signed|Any CPU
{8C96F2E9-681B-4201-8BDD-0AA901203725}.Release-Signed|Any CPU.Build.0 = Release-Signed|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release|Any CPU.Build.0 = Release|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release-Signed|Any CPU.ActiveCfg = Release-Signed|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release-Signed|Any CPU.Build.0 = Release-Signed|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

8
MathNet.Numerics.Portable.sln

@ -63,6 +63,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Numerics-Portable78", "src\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests-Portable78", "src\UnitTests\UnitTests-Portable78.csproj", "{2769BADC-02D9-48D9-88B4-C7E1C064BDF2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestData", "src\TestData\TestData.csproj", "{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -157,6 +159,12 @@ Global
{2769BADC-02D9-48D9-88B4-C7E1C064BDF2}.Release|Any CPU.Build.0 = Release|Any CPU
{2769BADC-02D9-48D9-88B4-C7E1C064BDF2}.Release-Signed|Any CPU.ActiveCfg = Release|Any CPU
{2769BADC-02D9-48D9-88B4-C7E1C064BDF2}.Release-Signed|Any CPU.Build.0 = Release|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release|Any CPU.Build.0 = Release|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release-Signed|Any CPU.ActiveCfg = Release-Signed|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release-Signed|Any CPU.Build.0 = Release-Signed|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

8
MathNet.Numerics.sln

@ -64,6 +64,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{039229DA-A
docs\content\Users.md = docs\content\Users.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestData", "src\TestData\TestData.csproj", "{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -95,6 +97,12 @@ Global
{DAF07AA8-C5C9-4963-98F7-2C3285064DAD}.Release|Any CPU.Build.0 = Release|Any CPU
{DAF07AA8-C5C9-4963-98F7-2C3285064DAD}.Release-Signed|Any CPU.ActiveCfg = Release-Signed|Any CPU
{DAF07AA8-C5C9-4963-98F7-2C3285064DAD}.Release-Signed|Any CPU.Build.0 = Release-Signed|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release|Any CPU.Build.0 = Release|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release-Signed|Any CPU.ActiveCfg = Release-Signed|Any CPU
{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}.Release-Signed|Any CPU.Build.0 = Release-Signed|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

353
src/DataUnitTests/Matlab/MatlabReaderTests.cs

@ -24,6 +24,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System.IO;
using System.Numerics;
using MathNet.Numerics.Data.Matlab;
using NUnit.Framework;
@ -42,11 +43,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadAllMatrices()
{
var matrices = MatlabReader.ReadAll<double>("./data/Matlab/collection.mat");
Assert.AreEqual(30, matrices.Count);
foreach (var matrix in matrices)
using (var stream = TestData.Data.ReadStream("Matlab.collection.mat"))
{
Assert.AreEqual(typeof (LinearAlgebra.Double.DenseMatrix), matrix.Value.GetType());
var matrices = MatlabReader.ReadAll<double>(stream);
Assert.AreEqual(30, matrices.Count);
foreach (var matrix in matrices)
{
Assert.AreEqual(typeof (LinearAlgebra.Double.DenseMatrix), matrix.Value.GetType());
}
}
}
@ -56,11 +60,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadFirstMatrix()
{
var matrix = MatlabReader.Read<double>("./data/Matlab/A.mat");
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Double.DenseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(100.108979553704, matrix.FrobeniusNorm(), 5);
using (var stream = TestData.Data.ReadStream("Matlab.A.mat"))
{
var matrix = MatlabReader.Read<double>(stream);
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Double.DenseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(100.108979553704, matrix.FrobeniusNorm(), 5);
}
}
/// <summary>
@ -69,11 +76,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadNamedMatrices()
{
var matrices = MatlabReader.ReadAll<double>("./data/Matlab/collection.mat", "Ad", "Au64");
Assert.AreEqual(2, matrices.Count);
foreach (var matrix in matrices)
using (var stream = TestData.Data.ReadStream("Matlab.collection.mat"))
{
Assert.AreEqual(typeof (LinearAlgebra.Double.DenseMatrix), matrix.Value.GetType());
var matrices = MatlabReader.ReadAll<double>(stream, "Ad", "Au64");
Assert.AreEqual(2, matrices.Count);
foreach (var matrix in matrices)
{
Assert.AreEqual(typeof (LinearAlgebra.Double.DenseMatrix), matrix.Value.GetType());
}
}
}
@ -83,13 +93,16 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadNamedMatrix()
{
var matrices = MatlabReader.ReadAll<double>("./data/Matlab/collection.mat", "Ad");
Assert.AreEqual(1, matrices.Count);
var ad = matrices["Ad"];
Assert.AreEqual(100, ad.RowCount);
Assert.AreEqual(100, ad.ColumnCount);
AssertHelpers.AlmostEqual(100.431635988639, ad.FrobeniusNorm(), 5);
Assert.AreEqual(typeof (LinearAlgebra.Double.DenseMatrix), ad.GetType());
using (var stream = TestData.Data.ReadStream("Matlab.collection.mat"))
{
var matrices = MatlabReader.ReadAll<double>(stream, "Ad");
Assert.AreEqual(1, matrices.Count);
var ad = matrices["Ad"];
Assert.AreEqual(100, ad.RowCount);
Assert.AreEqual(100, ad.ColumnCount);
AssertHelpers.AlmostEqual(100.431635988639, ad.FrobeniusNorm(), 5);
Assert.AreEqual(typeof (LinearAlgebra.Double.DenseMatrix), ad.GetType());
}
}
/// <summary>
@ -98,11 +111,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadNamedSparseMatrix()
{
var matrix = MatlabReader.Read<double>("./data/Matlab/sparse-small.mat", "S");
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Double.SparseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(17.6385090630805, matrix.FrobeniusNorm(), 12);
using (var stream = TestData.Data.ReadStream("Matlab.sparse-small.mat"))
{
var matrix = MatlabReader.Read<double>(stream, "S");
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Double.SparseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(17.6385090630805, matrix.FrobeniusNorm(), 12);
}
}
/// <summary>
@ -111,18 +127,21 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadComplexAllMatrices()
{
var matrices = MatlabReader.ReadAll<Complex>("./data/Matlab/complex.mat");
Assert.AreEqual(3, matrices.Count);
foreach (var matrix in matrices)
using (var stream = TestData.Data.ReadStream("Matlab.complex.mat"))
{
Assert.AreEqual(typeof (LinearAlgebra.Complex.DenseMatrix), matrix.Value.GetType());
var matrices = MatlabReader.ReadAll<Complex>(stream);
Assert.AreEqual(3, matrices.Count);
foreach (var matrix in matrices)
{
Assert.AreEqual(typeof (LinearAlgebra.Complex.DenseMatrix), matrix.Value.GetType());
}
var a = matrices["a"];
Assert.AreEqual(100, a.RowCount);
Assert.AreEqual(100, a.ColumnCount);
AssertHelpers.AlmostEqual(27.232498979698409, a.L2Norm(), 13);
}
var a = matrices["a"];
Assert.AreEqual(100, a.RowCount);
Assert.AreEqual(100, a.ColumnCount);
AssertHelpers.AlmostEqual(27.232498979698409, a.L2Norm(), 13);
}
/// <summary>
@ -131,18 +150,21 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadSparseComplexAllMatrices()
{
var matrices = MatlabReader.ReadAll<Complex>("./data/Matlab/sparse_complex.mat");
Assert.AreEqual(3, matrices.Count);
foreach (var matrix in matrices)
using (var stream = TestData.Data.ReadStream("Matlab.sparse_complex.mat"))
{
Assert.AreEqual(typeof (LinearAlgebra.Complex.SparseMatrix), matrix.Value.GetType());
var matrices = MatlabReader.ReadAll<Complex>(stream);
Assert.AreEqual(3, matrices.Count);
foreach (var matrix in matrices)
{
Assert.AreEqual(typeof (LinearAlgebra.Complex.SparseMatrix), matrix.Value.GetType());
}
var a = matrices["sa"];
Assert.AreEqual(100, a.RowCount);
Assert.AreEqual(100, a.ColumnCount);
AssertHelpers.AlmostEqual(13.223654390985379, a.L2Norm(), 13);
}
var a = matrices["sa"];
Assert.AreEqual(100, a.RowCount);
Assert.AreEqual(100, a.ColumnCount);
AssertHelpers.AlmostEqual(13.223654390985379, a.L2Norm(), 13);
}
/// <summary>
@ -151,11 +173,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadNonComplexAllMatrices()
{
var matrices = MatlabReader.ReadAll<Complex>("./data/Matlab/collection.mat");
Assert.AreEqual(30, matrices.Count);
foreach (var matrix in matrices)
using (var stream = TestData.Data.ReadStream("Matlab.collection.mat"))
{
Assert.AreEqual(typeof (LinearAlgebra.Complex.DenseMatrix), matrix.Value.GetType());
var matrices = MatlabReader.ReadAll<Complex>(stream);
Assert.AreEqual(30, matrices.Count);
foreach (var matrix in matrices)
{
Assert.AreEqual(typeof (LinearAlgebra.Complex.DenseMatrix), matrix.Value.GetType());
}
}
}
@ -165,11 +190,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadNonComplexFirstMatrix()
{
var matrix = MatlabReader.Read<Complex>("./data/Matlab/A.mat");
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Complex.DenseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(100.108979553704, matrix.FrobeniusNorm(), 13);
using (var stream = TestData.Data.ReadStream("Matlab.A.mat"))
{
var matrix = MatlabReader.Read<Complex>(stream);
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Complex.DenseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(100.108979553704, matrix.FrobeniusNorm(), 13);
}
}
/// <summary>
@ -178,11 +206,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadNonComplexNamedMatrices()
{
var matrices = MatlabReader.ReadAll<Complex>("./data/Matlab/collection.mat", "Ad", "Au64");
Assert.AreEqual(2, matrices.Count);
foreach (var matrix in matrices)
using (var stream = TestData.Data.ReadStream("Matlab.collection.mat"))
{
Assert.AreEqual(typeof (LinearAlgebra.Complex.DenseMatrix), matrix.Value.GetType());
var matrices = MatlabReader.ReadAll<Complex>(stream, "Ad", "Au64");
Assert.AreEqual(2, matrices.Count);
foreach (var matrix in matrices)
{
Assert.AreEqual(typeof (LinearAlgebra.Complex.DenseMatrix), matrix.Value.GetType());
}
}
}
@ -192,13 +223,16 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadNonComplexNamedMatrix()
{
var matrices = MatlabReader.ReadAll<Complex>("./data/Matlab/collection.mat", "Ad");
Assert.AreEqual(1, matrices.Count);
var ad = matrices["Ad"];
Assert.AreEqual(100, ad.RowCount);
Assert.AreEqual(100, ad.ColumnCount);
AssertHelpers.AlmostEqual(100.431635988639, ad.FrobeniusNorm(), 13);
Assert.AreEqual(typeof (LinearAlgebra.Complex.DenseMatrix), ad.GetType());
using (var stream = TestData.Data.ReadStream("Matlab.collection.mat"))
{
var matrices = MatlabReader.ReadAll<Complex>(stream, "Ad");
Assert.AreEqual(1, matrices.Count);
var ad = matrices["Ad"];
Assert.AreEqual(100, ad.RowCount);
Assert.AreEqual(100, ad.ColumnCount);
AssertHelpers.AlmostEqual(100.431635988639, ad.FrobeniusNorm(), 13);
Assert.AreEqual(typeof (LinearAlgebra.Complex.DenseMatrix), ad.GetType());
}
}
/// <summary>
@ -207,11 +241,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadNonComplexNamedSparseMatrix()
{
var matrix = MatlabReader.Read<Complex>("./data/Matlab/sparse-small.mat", "S");
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Complex.SparseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(17.6385090630805, matrix.FrobeniusNorm(), 12);
using (var stream = TestData.Data.ReadStream("Matlab.sparse-small.mat"))
{
var matrix = MatlabReader.Read<Complex>(stream, "S");
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Complex.SparseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(17.6385090630805, matrix.FrobeniusNorm(), 12);
}
}
/// <summary>
@ -220,18 +257,21 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadComplex32AllMatrices()
{
var matrices = MatlabReader.ReadAll<Complex32>("./data/Matlab/complex.mat");
Assert.AreEqual(3, matrices.Count);
foreach (var matrix in matrices)
using (var stream = TestData.Data.ReadStream("Matlab.complex.mat"))
{
Assert.AreEqual(typeof (LinearAlgebra.Complex32.DenseMatrix), matrix.Value.GetType());
var matrices = MatlabReader.ReadAll<Complex32>(stream);
Assert.AreEqual(3, matrices.Count);
foreach (var matrix in matrices)
{
Assert.AreEqual(typeof (LinearAlgebra.Complex32.DenseMatrix), matrix.Value.GetType());
}
var a = matrices["a"];
Assert.AreEqual(100, a.RowCount);
Assert.AreEqual(100, a.ColumnCount);
AssertHelpers.AlmostEqual(27.232498979698409, a.L2Norm(), 5);
}
var a = matrices["a"];
Assert.AreEqual(100, a.RowCount);
Assert.AreEqual(100, a.ColumnCount);
AssertHelpers.AlmostEqual(27.232498979698409, a.L2Norm(), 5);
}
/// <summary>
@ -240,18 +280,21 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadSparseComplex32AllMatrices()
{
var matrices = MatlabReader.ReadAll<Complex32>("./data/Matlab/sparse_complex.mat");
Assert.AreEqual(3, matrices.Count);
foreach (var matrix in matrices)
using (var stream = TestData.Data.ReadStream("Matlab.sparse_complex.mat"))
{
Assert.AreEqual(typeof (LinearAlgebra.Complex32.SparseMatrix), matrix.Value.GetType());
var matrices = MatlabReader.ReadAll<Complex32>(stream);
Assert.AreEqual(3, matrices.Count);
foreach (var matrix in matrices)
{
Assert.AreEqual(typeof (LinearAlgebra.Complex32.SparseMatrix), matrix.Value.GetType());
}
var a = matrices["sa"];
Assert.AreEqual(100, a.RowCount);
Assert.AreEqual(100, a.ColumnCount);
AssertHelpers.AlmostEqual(13.223654390985379, a.L2Norm(), 5);
}
var a = matrices["sa"];
Assert.AreEqual(100, a.RowCount);
Assert.AreEqual(100, a.ColumnCount);
AssertHelpers.AlmostEqual(13.223654390985379, a.L2Norm(), 5);
}
/// <summary>
@ -260,11 +303,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadNonComplex32AllMatrices()
{
var matrices = MatlabReader.ReadAll<Complex32>("./data/Matlab/collection.mat");
Assert.AreEqual(30, matrices.Count);
foreach (var matrix in matrices)
using (var stream = TestData.Data.ReadStream("Matlab.collection.mat"))
{
Assert.AreEqual(typeof (LinearAlgebra.Complex32.DenseMatrix), matrix.Value.GetType());
var matrices = MatlabReader.ReadAll<Complex32>(stream);
Assert.AreEqual(30, matrices.Count);
foreach (var matrix in matrices)
{
Assert.AreEqual(typeof (LinearAlgebra.Complex32.DenseMatrix), matrix.Value.GetType());
}
}
}
@ -274,11 +320,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadNonComplex32FirstMatrix()
{
var matrix = MatlabReader.Read<Complex32>("./data/Matlab/A.mat");
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Complex32.DenseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(100.108979553704, matrix.FrobeniusNorm(), 6);
using (var stream = TestData.Data.ReadStream("Matlab.A.mat"))
{
var matrix = MatlabReader.Read<Complex32>(stream);
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Complex32.DenseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(100.108979553704, matrix.FrobeniusNorm(), 6);
}
}
/// <summary>
@ -287,11 +336,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadNonComplex32NamedMatrices()
{
var matrices = MatlabReader.ReadAll<Complex32>("./data/Matlab/collection.mat", "Ad", "Au64");
Assert.AreEqual(2, matrices.Count);
foreach (var matrix in matrices)
using (var stream = TestData.Data.ReadStream("Matlab.collection.mat"))
{
Assert.AreEqual(typeof (LinearAlgebra.Complex32.DenseMatrix), matrix.Value.GetType());
var matrices = MatlabReader.ReadAll<Complex32>(stream, "Ad", "Au64");
Assert.AreEqual(2, matrices.Count);
foreach (var matrix in matrices)
{
Assert.AreEqual(typeof (LinearAlgebra.Complex32.DenseMatrix), matrix.Value.GetType());
}
}
}
@ -301,13 +353,16 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadNonComplex32NamedMatrix()
{
var matrices = MatlabReader.ReadAll<Complex32>("./data/Matlab/collection.mat", "Ad");
Assert.AreEqual(1, matrices.Count);
var ad = matrices["Ad"];
Assert.AreEqual(100, ad.RowCount);
Assert.AreEqual(100, ad.ColumnCount);
AssertHelpers.AlmostEqual(100.431635988639, ad.FrobeniusNorm(), 6);
Assert.AreEqual(typeof (LinearAlgebra.Complex32.DenseMatrix), ad.GetType());
using (var stream = TestData.Data.ReadStream("Matlab.collection.mat"))
{
var matrices = MatlabReader.ReadAll<Complex32>(stream, "Ad");
Assert.AreEqual(1, matrices.Count);
var ad = matrices["Ad"];
Assert.AreEqual(100, ad.RowCount);
Assert.AreEqual(100, ad.ColumnCount);
AssertHelpers.AlmostEqual(100.431635988639, ad.FrobeniusNorm(), 6);
Assert.AreEqual(typeof (LinearAlgebra.Complex32.DenseMatrix), ad.GetType());
}
}
/// <summary>
@ -316,11 +371,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadNonComplex32NamedSparseMatrix()
{
var matrix = MatlabReader.Read<Complex32>("./data/Matlab/sparse-small.mat", "S");
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Complex32.SparseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(17.6385090630805, matrix.FrobeniusNorm(), 6);
using (var stream = TestData.Data.ReadStream("Matlab.sparse-small.mat"))
{
var matrix = MatlabReader.Read<Complex32>(stream, "S");
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Complex32.SparseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(17.6385090630805, matrix.FrobeniusNorm(), 6);
}
}
/// <summary>
@ -329,11 +387,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadFloatAllMatrices()
{
var matrices = MatlabReader.ReadAll<float>("./data/Matlab/collection.mat");
Assert.AreEqual(30, matrices.Count);
foreach (var matrix in matrices)
using (var stream = TestData.Data.ReadStream("Matlab.collection.mat"))
{
Assert.AreEqual(typeof (LinearAlgebra.Single.DenseMatrix), matrix.Value.GetType());
var matrices = MatlabReader.ReadAll<float>(stream);
Assert.AreEqual(30, matrices.Count);
foreach (var matrix in matrices)
{
Assert.AreEqual(typeof (LinearAlgebra.Single.DenseMatrix), matrix.Value.GetType());
}
}
}
@ -343,11 +404,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadFloatFirstMatrix()
{
var matrix = MatlabReader.Read<float>("./data/Matlab/A.mat");
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Single.DenseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(100.108979553704f, matrix.FrobeniusNorm(), 6);
using (var stream = TestData.Data.ReadStream("Matlab.A.mat"))
{
var matrix = MatlabReader.Read<float>(stream);
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Single.DenseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(100.108979553704f, matrix.FrobeniusNorm(), 6);
}
}
/// <summary>
@ -356,11 +420,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadFloatNamedMatrices()
{
var matrices = MatlabReader.ReadAll<float>("./data/Matlab/collection.mat", "Ad", "Au64");
Assert.AreEqual(2, matrices.Count);
foreach (var matrix in matrices)
using (var stream = TestData.Data.ReadStream("Matlab.collection.mat"))
{
Assert.AreEqual(typeof (LinearAlgebra.Single.DenseMatrix), matrix.Value.GetType());
var matrices = MatlabReader.ReadAll<float>(stream, "Ad", "Au64");
Assert.AreEqual(2, matrices.Count);
foreach (var matrix in matrices)
{
Assert.AreEqual(typeof (LinearAlgebra.Single.DenseMatrix), matrix.Value.GetType());
}
}
}
@ -370,13 +437,16 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadFloatNamedMatrix()
{
var matrices = MatlabReader.ReadAll<float>("./data/Matlab/collection.mat", "Ad");
Assert.AreEqual(1, matrices.Count);
var ad = matrices["Ad"];
Assert.AreEqual(100, ad.RowCount);
Assert.AreEqual(100, ad.ColumnCount);
AssertHelpers.AlmostEqual(100.431635988639f, ad.FrobeniusNorm(), 6);
Assert.AreEqual(typeof (LinearAlgebra.Single.DenseMatrix), ad.GetType());
using (var stream = TestData.Data.ReadStream("Matlab.collection.mat"))
{
var matrices = MatlabReader.ReadAll<float>(stream, "Ad");
Assert.AreEqual(1, matrices.Count);
var ad = matrices["Ad"];
Assert.AreEqual(100, ad.RowCount);
Assert.AreEqual(100, ad.ColumnCount);
AssertHelpers.AlmostEqual(100.431635988639f, ad.FrobeniusNorm(), 6);
Assert.AreEqual(typeof (LinearAlgebra.Single.DenseMatrix), ad.GetType());
}
}
/// <summary>
@ -385,11 +455,14 @@ namespace MathNet.Numerics.Data.UnitTests.Matlab
[Test]
public void CanReadFloatNamedSparseMatrix()
{
var matrix = MatlabReader.Read<float>("./data/Matlab/sparse-small.mat", "S");
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Single.SparseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(17.6385090630805f, matrix.FrobeniusNorm(), 6);
using (var stream = TestData.Data.ReadStream("Matlab.sparse-small.mat"))
{
var matrix = MatlabReader.Read<float>(stream, "S");
Assert.AreEqual(100, matrix.RowCount);
Assert.AreEqual(100, matrix.ColumnCount);
Assert.AreEqual(typeof (LinearAlgebra.Single.SparseMatrix), matrix.GetType());
AssertHelpers.AlmostEqual(17.6385090630805f, matrix.FrobeniusNorm(), 6);
}
}
}
}

96
src/DataUnitTests/Text/MatrixMarketReaderTests.cs

@ -42,63 +42,75 @@ namespace MathNet.Numerics.Data.UnitTests.Text
[Test]
public void CanReadFudao007AsDouble()
{
var m = MatrixMarketReader.ReadMatrix<double>("./data/MatrixMarket/fidap007.mtx");
Assert.IsInstanceOf<LinearAlgebra.Double.SparseMatrix>(m);
Assert.AreEqual(1633, m.RowCount);
Assert.AreEqual(1633, m.ColumnCount);
Assert.GreaterOrEqual(54487, ((LinearAlgebra.Double.SparseMatrix) m).NonZerosCount);
Assert.Less(46000, ((LinearAlgebra.Double.SparseMatrix) m).NonZerosCount);
Assert.AreEqual(-6.8596032449032e+06d, m[1604, 1631]);
Assert.AreEqual(-9.1914585107976e+06d, m[1616, 1628]);
Assert.AreEqual(7.9403870156486e+07d, m[905, 726]);
using (Stream stream = TestData.Data.ReadStream("MatrixMarket.fidap007.mtx"))
{
var m = MatrixMarketReader.ReadMatrix<double>(stream);
Assert.IsInstanceOf<LinearAlgebra.Double.SparseMatrix>(m);
Assert.AreEqual(1633, m.RowCount);
Assert.AreEqual(1633, m.ColumnCount);
Assert.GreaterOrEqual(54487, ((LinearAlgebra.Double.SparseMatrix)m).NonZerosCount);
Assert.Less(46000, ((LinearAlgebra.Double.SparseMatrix)m).NonZerosCount);
Assert.AreEqual(-6.8596032449032e+06d, m[1604, 1631]);
Assert.AreEqual(-9.1914585107976e+06d, m[1616, 1628]);
Assert.AreEqual(7.9403870156486e+07d, m[905, 726]);
}
}
[Test]
public void CanReadFudao007AsSingle()
{
var m = MatrixMarketReader.ReadMatrix<float>("./data/MatrixMarket/fidap007.mtx");
Assert.IsInstanceOf<LinearAlgebra.Single.SparseMatrix>(m);
Assert.AreEqual(1633, m.RowCount);
Assert.AreEqual(1633, m.ColumnCount);
Assert.GreaterOrEqual(54487, ((LinearAlgebra.Single.SparseMatrix)m).NonZerosCount);
Assert.Less(46000, ((LinearAlgebra.Single.SparseMatrix)m).NonZerosCount);
Assert.AreEqual(-6.8596032449032e+06f, m[1604, 1631]);
Assert.AreEqual(-9.1914585107976e+06f, m[1616, 1628]);
Assert.AreEqual(7.9403870156486e+07f, m[905, 726]);
using (Stream stream = TestData.Data.ReadStream("MatrixMarket.fidap007.mtx"))
{
var m = MatrixMarketReader.ReadMatrix<float>(stream);
Assert.IsInstanceOf<LinearAlgebra.Single.SparseMatrix>(m);
Assert.AreEqual(1633, m.RowCount);
Assert.AreEqual(1633, m.ColumnCount);
Assert.GreaterOrEqual(54487, ((LinearAlgebra.Single.SparseMatrix)m).NonZerosCount);
Assert.Less(46000, ((LinearAlgebra.Single.SparseMatrix)m).NonZerosCount);
Assert.AreEqual(-6.8596032449032e+06f, m[1604, 1631]);
Assert.AreEqual(-9.1914585107976e+06f, m[1616, 1628]);
Assert.AreEqual(7.9403870156486e+07f, m[905, 726]);
}
}
[Test]
public void CanReadFudao007AsComplex()
{
var m = MatrixMarketReader.ReadMatrix<Complex>("./data/MatrixMarket/fidap007.mtx");
Assert.IsInstanceOf<LinearAlgebra.Complex.SparseMatrix>(m);
Assert.AreEqual(1633, m.RowCount);
Assert.AreEqual(1633, m.ColumnCount);
Assert.GreaterOrEqual(54487, ((LinearAlgebra.Complex.SparseMatrix)m).NonZerosCount);
Assert.Less(46000, ((LinearAlgebra.Complex.SparseMatrix)m).NonZerosCount);
Assert.AreEqual(-6.8596032449032e+06d, m[1604, 1631].Real);
Assert.AreEqual(0.0d, m[1604, 1631].Imaginary);
Assert.AreEqual(-9.1914585107976e+06d, m[1616, 1628].Real);
Assert.AreEqual(0.0d, m[1616, 1628].Imaginary);
Assert.AreEqual(7.9403870156486e+07d, m[905, 726].Real);
Assert.AreEqual(0.0d, m[905, 726].Imaginary);
using (TextReader reader = TestData.Data.ReadText("MatrixMarket.fidap007.mtx"))
{
var m = MatrixMarketReader.ReadMatrix<Complex>(reader);
Assert.IsInstanceOf<LinearAlgebra.Complex.SparseMatrix>(m);
Assert.AreEqual(1633, m.RowCount);
Assert.AreEqual(1633, m.ColumnCount);
Assert.GreaterOrEqual(54487, ((LinearAlgebra.Complex.SparseMatrix)m).NonZerosCount);
Assert.Less(46000, ((LinearAlgebra.Complex.SparseMatrix)m).NonZerosCount);
Assert.AreEqual(-6.8596032449032e+06d, m[1604, 1631].Real);
Assert.AreEqual(0.0d, m[1604, 1631].Imaginary);
Assert.AreEqual(-9.1914585107976e+06d, m[1616, 1628].Real);
Assert.AreEqual(0.0d, m[1616, 1628].Imaginary);
Assert.AreEqual(7.9403870156486e+07d, m[905, 726].Real);
Assert.AreEqual(0.0d, m[905, 726].Imaginary);
}
}
[Test]
public void CanReadFudao007AsComplex32()
{
var m = MatrixMarketReader.ReadMatrix<Complex32>("./data/MatrixMarket/fidap007.mtx");
Assert.IsInstanceOf<LinearAlgebra.Complex32.SparseMatrix>(m);
Assert.AreEqual(1633, m.RowCount);
Assert.AreEqual(1633, m.ColumnCount);
Assert.GreaterOrEqual(54487, ((LinearAlgebra.Complex32.SparseMatrix) m).NonZerosCount);
Assert.Less(46000, ((LinearAlgebra.Complex32.SparseMatrix) m).NonZerosCount);
Assert.AreEqual(-6.8596032449032e+06f, m[1604, 1631].Real);
Assert.AreEqual(0.0f, m[1604, 1631].Imaginary);
Assert.AreEqual(-9.1914585107976e+06f, m[1616, 1628].Real);
Assert.AreEqual(0.0f, m[1616, 1628].Imaginary);
Assert.AreEqual(7.9403870156486e+07f, m[905, 726].Real);
Assert.AreEqual(0.0f, m[905, 726].Imaginary);
using (TextReader reader = TestData.Data.ReadText("MatrixMarket.fidap007.mtx"))
{
var m = MatrixMarketReader.ReadMatrix<Complex32>(reader);
Assert.IsInstanceOf<LinearAlgebra.Complex32.SparseMatrix>(m);
Assert.AreEqual(1633, m.RowCount);
Assert.AreEqual(1633, m.ColumnCount);
Assert.GreaterOrEqual(54487, ((LinearAlgebra.Complex32.SparseMatrix)m).NonZerosCount);
Assert.Less(46000, ((LinearAlgebra.Complex32.SparseMatrix)m).NonZerosCount);
Assert.AreEqual(-6.8596032449032e+06f, m[1604, 1631].Real);
Assert.AreEqual(0.0f, m[1604, 1631].Imaginary);
Assert.AreEqual(-9.1914585107976e+06f, m[1616, 1628].Real);
Assert.AreEqual(0.0f, m[1616, 1628].Imaginary);
Assert.AreEqual(7.9403870156486e+07f, m[905, 726].Real);
Assert.AreEqual(0.0f, m[905, 726].Imaginary);
}
}
[Test]

40
src/DataUnitTests/UnitTests.csproj

@ -50,42 +50,6 @@
<Compile Include="Text\MatrixMarketWriterTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\data\Matlab\A.mat">
<Link>data\matlab\A.mat</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\collection-nocompress.mat">
<Link>data\matlab\collection-nocompress.mat</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\collection.mat">
<Link>data\matlab\collection.mat</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\complex.mat">
<Link>data\matlab\complex.mat</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\sparse-large.mat">
<Link>data\matlab\sparse-large.mat</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\sparse-small.mat">
<Link>data\matlab\sparse-small.mat</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\sparse_complex.mat">
<Link>data\matlab\sparse_complex.mat</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\v.mat">
<Link>data\matlab\v.mat</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\MatrixMarket\fidap007.mtx">
<Link>data\MatrixMarket\fidap007.mtx</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="paket.references">
<SubType>Designer</SubType>
</None>
@ -99,6 +63,10 @@
<Project>{9d3a08e1-6b96-4552-a535-412e589b3264}</Project>
<Name>Text</Name>
</ProjectReference>
<ProjectReference Include="..\TestData\TestData.csproj">
<Project>{af3253c9-4db5-45a0-98cf-c105fda9da47}</Project>
<Name>TestData</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

5
src/FSharpUnitTests/FSharpUnitTests-Net35.fsproj

@ -72,6 +72,11 @@
<None Include="paket.references" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TestData\TestData.csproj">
<Name>TestData</Name>
<Project>{af3253c9-4db5-45a0-98cf-c105fda9da47}</Project>
<Private>True</Private>
</ProjectReference>
<Reference Include="FSharp.Core, Version=2.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>False</Private>
</Reference>

5
src/FSharpUnitTests/FSharpUnitTests-Portable47.fsproj

@ -40,6 +40,11 @@
</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TestData\TestData.csproj">
<Name>TestData</Name>
<Project>{af3253c9-4db5-45a0-98cf-c105fda9da47}</Project>
<Private>True</Private>
</ProjectReference>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />

5
src/FSharpUnitTests/FSharpUnitTests.fsproj

@ -49,6 +49,11 @@
<DefineConstants>$(DefineConstants);NOFSSLICESET1D</DefineConstants>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TestData\TestData.csproj">
<Name>TestData</Name>
<Project>{af3253c9-4db5-45a0-98cf-c105fda9da47}</Project>
<Private>True</Private>
</ProjectReference>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />

38
src/TestData/Data.cs

@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.IO;
using System.Reflection;
namespace MathNet.Numerics.TestData
{
public static class Data
{
static readonly Assembly DataAssembly = typeof (Data).Assembly;
public static Stream ReadStream(string name)
{
return DataAssembly.GetManifestResourceStream("MathNet.Numerics.TestData.Data." + name);
}
public static TextReader ReadText(string name)
{
var stream = ReadStream(name);
return new StreamReader(stream);
}
public static string[] ReadAllLines(string name)
{
List<string> lines = new List<string>();
using (TextReader reader = ReadText(name))
{
string line;
while ((line = reader.ReadLine()) != null)
{
lines.Add(line);
}
}
return lines.ToArray();
}
}
}

36
src/TestData/Properties/AssemblyInfo.cs

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Math.NET Numerics Test Data")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Math.NET Project")]
[assembly: AssemblyProduct("Math.NET Numerics")]
[assembly: AssemblyCopyright("Copyright (c) Math.NET Project")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a4a6a08e-5265-4608-a43d-e4f2e210ba2d")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

290
src/TestData/TestData.csproj

@ -0,0 +1,290 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MathNet.Numerics.TestData</RootNamespace>
<AssemblyName>MathNet.Numerics.TestData</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<AssemblyOriginatorKeyFile>..\MathNet.Numerics.snk</AssemblyOriginatorKeyFile>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>..\..\out\test\Net35\</OutputPath>
<IntermediateOutputPath>..\..\obj\test\Net35\</IntermediateOutputPath>
<BaseIntermediateOutputPath>..\..\obj\test\Net35\</BaseIntermediateOutputPath>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<NoWarn>1591</NoWarn>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<OutputPath>..\..\out\test-debug\Net35\</OutputPath>
<IntermediateOutputPath>..\..\obj\test-debug\Net35\</IntermediateOutputPath>
<BaseIntermediateOutputPath>..\..\obj\test-debug\Net35\</BaseIntermediateOutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<NoWarn>1591</NoWarn>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Signed|AnyCPU'">
<OutputPath>..\..\out\test-signed\Net35\</OutputPath>
<IntermediateOutputPath>..\..\obj\test-signed\Net35\</IntermediateOutputPath>
<BaseIntermediateOutputPath>..\..\obj\test-signed\Net35\</BaseIntermediateOutputPath>
<!-- Conditional Strong Name: YES -->
<SignAssembly>true</SignAssembly>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE;STRONGNAME</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<NoWarn>1591</NoWarn>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Data.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\..\data\Codeplex-5667.csv">
<Link>Data\Codeplex-5667.csv</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\Github-Cureos-1.csv">
<Link>Data\Github-Cureos-1.csv</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\matlab\A.mat">
<Link>Data\Matlab\A.mat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\matlab\collection-nocompress.mat">
<Link>Data\Matlab\collection-nocompress.mat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\matlab\collection.mat">
<Link>Data\Matlab\collection.mat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\matlab\complex.mat">
<Link>Data\Matlab\complex.mat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\matlab\sparse-large.mat">
<Link>Data\Matlab\sparse-large.mat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\matlab\sparse-small.mat">
<Link>Data\Matlab\sparse-small.mat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\matlab\sparse_complex.mat">
<Link>Data\Matlab\sparse_complex.mat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\matlab\v.mat">
<Link>Data\Matlab\v.mat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\AtmWtAgt.dat">
<Link>Data\NIST\AtmWtAgt.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Bennett5.dat">
<Link>Data\NIST\Bennett5.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\BoxBOD.dat">
<Link>Data\NIST\BoxBOD.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Chwirut1.dat">
<Link>Data\NIST\Chwirut1.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Chwirut2.dat">
<Link>Data\NIST\Chwirut2.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\DanWood.dat">
<Link>Data\NIST\DanWood.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Eckerle4.dat">
<Link>Data\NIST\Eckerle4.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\ENSO.dat">
<Link>Data\NIST\ENSO.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Filip.dat">
<Link>Data\NIST\Filip.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Gauss1.dat">
<Link>Data\NIST\Gauss1.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Gauss2.dat">
<Link>Data\NIST\Gauss2.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Gauss3.dat">
<Link>Data\NIST\Gauss3.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Hahn1.dat">
<Link>Data\NIST\Hahn1.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Kirby2.dat">
<Link>Data\NIST\Kirby2.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Lanczos1.dat">
<Link>Data\NIST\Lanczos1.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Lanczos2.dat">
<Link>Data\NIST\Lanczos2.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Lanczos3.dat">
<Link>Data\NIST\Lanczos3.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Lew.dat">
<Link>Data\NIST\Lew.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Longley.dat">
<Link>Data\NIST\Longley.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Lottery.dat">
<Link>Data\NIST\Lottery.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Mavro.dat">
<Link>Data\NIST\Mavro.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Meixner.dat">
<Link>Data\NIST\Meixner.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\MGH09.dat">
<Link>Data\NIST\MGH09.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\MGH10.dat">
<Link>Data\NIST\MGH10.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\MGH17.dat">
<Link>Data\NIST\MGH17.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Michelso.dat">
<Link>Data\NIST\Michelso.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Misra1a.dat">
<Link>Data\NIST\Misra1a.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Misra1b.dat">
<Link>Data\NIST\Misra1b.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Misra1c.dat">
<Link>Data\NIST\Misra1c.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Misra1d.dat">
<Link>Data\NIST\Misra1d.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Nelson.dat">
<Link>Data\NIST\Nelson.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\NoInt1.dat">
<Link>Data\NIST\NoInt1.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\NoInt2.dat">
<Link>Data\NIST\NoInt2.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Norris.dat">
<Link>Data\NIST\Norris.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\NumAcc1.dat">
<Link>Data\NIST\NumAcc1.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\NumAcc2.dat">
<Link>Data\NIST\NumAcc2.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\NumAcc3.dat">
<Link>Data\NIST\NumAcc3.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\NumAcc4.dat">
<Link>Data\NIST\NumAcc4.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Pontius.dat">
<Link>Data\NIST\Pontius.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Rat42.dat">
<Link>Data\NIST\Rat42.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Rat43.dat">
<Link>Data\NIST\Rat43.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Roszman1.dat">
<Link>Data\NIST\Roszman1.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\SiRstvt.dat">
<Link>Data\NIST\SiRstvt.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\SmLs01t.dat">
<Link>Data\NIST\SmLs01t.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\SmLs02t.dat">
<Link>Data\NIST\SmLs02t.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\SmLs03t.dat">
<Link>Data\NIST\SmLs03t.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\SmLs04t.dat">
<Link>Data\NIST\SmLs04t.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\SmLs05t.dat">
<Link>Data\NIST\SmLs05t.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\SmLs06t.dat">
<Link>Data\NIST\SmLs06t.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\SmLs07t.dat">
<Link>Data\NIST\SmLs07t.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\SmLs08t.dat">
<Link>Data\NIST\SmLs08t.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\SmLs09t.dat">
<Link>Data\NIST\SmLs09t.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Thurber.dat">
<Link>Data\NIST\Thurber.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Wampler1.dat">
<Link>Data\NIST\Wampler1.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Wampler2.dat">
<Link>Data\NIST\Wampler2.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Wampler3.dat">
<Link>Data\NIST\Wampler3.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Wampler4.dat">
<Link>Data\NIST\Wampler4.dat</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\nist\Wampler5.dat">
<Link>Data\NIST\Wampler5.dat</Link>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\..\data\MatrixMarket\fidap007.mtx">
<Link>Data\MatrixMarket\fidap007.mtx</Link>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

6
src/UnitTests/InterpolationTests/NevillePolynomialTest.cs

@ -30,9 +30,9 @@
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using MathNet.Numerics.Interpolation;
using MathNet.Numerics.TestData;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.InterpolationTests
@ -133,8 +133,8 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests
public void Interpolate_LogLogAttenuationData_InterpolationShouldNotYieldNaN(
[Values(0.0025, 0.035, 0.45, 5.5, 18.5, 35.0)] double value)
{
var data = File.ReadAllLines(@"./data/Github-Cureos-1.csv").
Select(line =>
var data = Data.ReadAllLines(@"Github-Cureos-1.csv")
.Select(line =>
{
var vals = line.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
return new Tuple<string, string>(vals[2], vals[3]);

6
src/UnitTests/StatisticsTests/CorrelationTests.cs

@ -40,7 +40,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests
/// <summary>
/// Correlation tests
/// </summary>
/// <remarks>NOTE: this class is not included into Silverlight version, because it uses data from local files.
/// <remarks>NOTE: this class is not included into Silverlight version, because it uses data from local files.
/// In Silverlight access to local files is forbidden, except several cases.</remarks>
[TestFixture, Category("Statistics")]
public class CorrelationTests
@ -55,9 +55,9 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests
/// </summary>
public CorrelationTests()
{
var lottery = new StatTestData("./data/NIST/Lottery.dat");
var lottery = new StatTestData("NIST.Lottery.dat");
_data.Add("lottery", lottery);
var lew = new StatTestData("./data/NIST/Lew.dat");
var lew = new StatTestData("NIST.Lew.dat");
_data.Add("lew", lew);
}

18
src/UnitTests/StatisticsTests/DescriptiveStatisticsTests.cs

@ -54,15 +54,15 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests
/// </summary>
public DescriptiveStatisticsTests()
{
_data.Add("lottery", new StatTestData("./data/NIST/Lottery.dat"));
_data.Add("lew", new StatTestData("./data/NIST/Lew.dat"));
_data.Add("mavro", new StatTestData("./data/NIST/Mavro.dat"));
_data.Add("michelso", new StatTestData("./data/NIST/Michelso.dat"));
_data.Add("numacc1", new StatTestData("./data/NIST/NumAcc1.dat"));
_data.Add("numacc2", new StatTestData("./data/NIST/NumAcc2.dat"));
_data.Add("numacc3", new StatTestData("./data/NIST/NumAcc3.dat"));
_data.Add("numacc4", new StatTestData("./data/NIST/NumAcc4.dat"));
_data.Add("meixner", new StatTestData("./data/NIST/Meixner.dat"));
_data.Add("lottery", new StatTestData("NIST.Lottery.dat"));
_data.Add("lew", new StatTestData("NIST.Lew.dat"));
_data.Add("mavro", new StatTestData("NIST.Mavro.dat"));
_data.Add("michelso", new StatTestData("NIST.Michelso.dat"));
_data.Add("numacc1", new StatTestData("NIST.NumAcc1.dat"));
_data.Add("numacc2", new StatTestData("NIST.NumAcc2.dat"));
_data.Add("numacc3", new StatTestData("NIST.NumAcc3.dat"));
_data.Add("numacc4", new StatTestData("NIST.NumAcc4.dat"));
_data.Add("meixner", new StatTestData("NIST.Meixner.dat"));
}
/// <summary>

18
src/UnitTests/StatisticsTests/RunningStatisticsTests.cs

@ -56,15 +56,15 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests
/// </summary>
public RunningStatisticsTests()
{
_data.Add("lottery", new StatTestData("./data/NIST/Lottery.dat"));
_data.Add("lew", new StatTestData("./data/NIST/Lew.dat"));
_data.Add("mavro", new StatTestData("./data/NIST/Mavro.dat"));
_data.Add("michelso", new StatTestData("./data/NIST/Michelso.dat"));
_data.Add("numacc1", new StatTestData("./data/NIST/NumAcc1.dat"));
_data.Add("numacc2", new StatTestData("./data/NIST/NumAcc2.dat"));
_data.Add("numacc3", new StatTestData("./data/NIST/NumAcc3.dat"));
_data.Add("numacc4", new StatTestData("./data/NIST/NumAcc4.dat"));
_data.Add("meixner", new StatTestData("./data/NIST/Meixner.dat"));
_data.Add("lottery", new StatTestData("NIST.Lottery.dat"));
_data.Add("lew", new StatTestData("NIST.Lew.dat"));
_data.Add("mavro", new StatTestData("NIST.Mavro.dat"));
_data.Add("michelso", new StatTestData("NIST.Michelso.dat"));
_data.Add("numacc1", new StatTestData("NIST.NumAcc1.dat"));
_data.Add("numacc2", new StatTestData("NIST.NumAcc2.dat"));
_data.Add("numacc3", new StatTestData("NIST.NumAcc3.dat"));
_data.Add("numacc4", new StatTestData("NIST.NumAcc4.dat"));
_data.Add("meixner", new StatTestData("NIST.Meixner.dat"));
}
/// <summary>

8
src/UnitTests/StatisticsTests/StatTestData.cs

@ -30,12 +30,12 @@
using System;
using System.Globalization;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace MathNet.Numerics.UnitTests.StatisticsTests
{
using System.Collections.Generic;
using System.IO;
using System.Linq;
/// <summary>
/// Statistics data.
@ -68,7 +68,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests
/// <param name="file">Path to the file.</param>
public StatTestData(string file)
{
using (var reader = new StreamReader(file))
using (var reader = TestData.Data.ReadText(file))
{
var line = reader.ReadLine().Trim();

21
src/UnitTests/StatisticsTests/StatisticsTests.cs

@ -34,6 +34,7 @@ using System.IO;
using System.Linq;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.Random;
using MathNet.Numerics.TestData;
using NUnit.Framework;
// ReSharper disable InvokeAsExtensionMethod
@ -50,15 +51,15 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests
{
readonly IDictionary<string, StatTestData> _data = new Dictionary<string, StatTestData>
{
{ "lottery", new StatTestData("./data/NIST/Lottery.dat") },
{ "lew", new StatTestData("./data/NIST/Lew.dat") },
{ "mavro", new StatTestData("./data/NIST/Mavro.dat") },
{ "michelso", new StatTestData("./data/NIST/Michelso.dat") },
{ "numacc1", new StatTestData("./data/NIST/NumAcc1.dat") },
{ "numacc2", new StatTestData("./data/NIST/NumAcc2.dat") },
{ "numacc3", new StatTestData("./data/NIST/NumAcc3.dat") },
{ "numacc4", new StatTestData("./data/NIST/NumAcc4.dat") },
{ "meixner", new StatTestData("./data/NIST/Meixner.dat") }
{ "lottery", new StatTestData("NIST.Lottery.dat") },
{ "lew", new StatTestData("NIST.Lew.dat") },
{ "mavro", new StatTestData("NIST.Mavro.dat") },
{ "michelso", new StatTestData("NIST.Michelso.dat") },
{ "numacc1", new StatTestData("NIST.NumAcc1.dat") },
{ "numacc2", new StatTestData("NIST.NumAcc2.dat") },
{ "numacc3", new StatTestData("NIST.NumAcc3.dat") },
{ "numacc4", new StatTestData("NIST.NumAcc4.dat") },
{ "meixner", new StatTestData("NIST.Meixner.dat") }
};
[Test]
@ -987,7 +988,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests
[Test]
public void Median_CodeplexIssue5667()
{
var seq = File.ReadAllLines("./data/Codeplex-5667.csv").Select(double.Parse);
var seq = Data.ReadAllLines("Codeplex-5667.csv").Select(double.Parse);
Assert.AreEqual(1.0, Statistics.Median(seq));
var array = seq.ToArray();

4
src/UnitTests/UnitTests-Net35.csproj

@ -341,6 +341,10 @@
<Project>{E54E712D-EB6B-4FBF-B29A-6BB95E719BAC}</Project>
<Name>Numerics-Net35</Name>
</ProjectReference>
<ProjectReference Include="..\TestData\TestData.csproj">
<Project>{af3253c9-4db5-45a0-98cf-c105fda9da47}</Project>
<Name>TestData</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>

4
src/UnitTests/UnitTests-Portable259.csproj

@ -328,6 +328,10 @@
<Project>{1C8DBFB2-DB75-4C4B-888B-4AF314FCE3C3}</Project>
<Name>Numerics-Portable259</Name>
</ProjectReference>
<ProjectReference Include="..\TestData\TestData.csproj">
<Project>{af3253c9-4db5-45a0-98cf-c105fda9da47}</Project>
<Name>TestData</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>

4
src/UnitTests/UnitTests-Portable328.csproj

@ -328,6 +328,10 @@
<Project>{1A3065FD-105D-4AF1-85B9-0A4A26FFB353}</Project>
<Name>Numerics-Portable328</Name>
</ProjectReference>
<ProjectReference Include="..\TestData\TestData.csproj">
<Project>{af3253c9-4db5-45a0-98cf-c105fda9da47}</Project>
<Name>TestData</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>

4
src/UnitTests/UnitTests-Portable47.csproj

@ -38,6 +38,10 @@
<NoWarn>1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TestData\TestData.csproj">
<Project>{af3253c9-4db5-45a0-98cf-c105fda9da47}</Project>
<Name>TestData</Name>
</ProjectReference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />

4
src/UnitTests/UnitTests-Portable7.csproj

@ -38,6 +38,10 @@
<NoWarn>1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TestData\TestData.csproj">
<Project>{af3253c9-4db5-45a0-98cf-c105fda9da47}</Project>
<Name>TestData</Name>
</ProjectReference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />

4
src/UnitTests/UnitTests-Portable78.csproj

@ -38,6 +38,10 @@
<NoWarn>1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TestData\TestData.csproj">
<Project>{af3253c9-4db5-45a0-98cf-c105fda9da47}</Project>
<Name>TestData</Name>
</ProjectReference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />

277
src/UnitTests/UnitTests.csproj

@ -60,6 +60,10 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TestData\TestData.csproj">
<Project>{af3253c9-4db5-45a0-98cf-c105fda9da47}</Project>
<Name>TestData</Name>
</ProjectReference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
@ -396,279 +400,7 @@
<Compile Include="UseLinearAlgebraProvider.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\data\Codeplex-5667.csv">
<Link>data\Codeplex-5667.csv</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Github-Cureos-1.csv">
<Link>data\Github-Cureos-1.csv</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\A.mat">
<Link>data\Matlab\A.mat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\collection-nocompress.mat">
<Link>data\Matlab\collection-nocompress.mat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\collection.mat">
<Link>data\Matlab\collection.mat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\complex.mat">
<Link>data\Matlab\complex.mat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\sparse-large.mat">
<Link>data\Matlab\sparse-large.mat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\sparse-small.mat">
<Link>data\Matlab\sparse-small.mat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\sparse_complex.mat">
<Link>data\Matlab\sparse_complex.mat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\Matlab\v.mat">
<Link>data\Matlab\v.mat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\AtmWtAgt.dat">
<Link>data\NIST\AtmWtAgt.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Bennett5.dat">
<Link>data\NIST\Bennett5.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\BoxBOD.dat">
<Link>data\NIST\BoxBOD.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Chwirut1.dat">
<Link>data\NIST\Chwirut1.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Chwirut2.dat">
<Link>data\NIST\Chwirut2.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\DanWood.dat">
<Link>data\NIST\DanWood.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Eckerle4.dat">
<Link>data\NIST\Eckerle4.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\ENSO.dat">
<Link>data\NIST\ENSO.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Filip.dat">
<Link>data\NIST\Filip.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Gauss1.dat">
<Link>data\NIST\Gauss1.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Gauss2.dat">
<Link>data\NIST\Gauss2.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Gauss3.dat">
<Link>data\NIST\Gauss3.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Hahn1.dat">
<Link>data\NIST\Hahn1.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Kirby2.dat">
<Link>data\NIST\Kirby2.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Lanczos1.dat">
<Link>data\NIST\Lanczos1.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Lanczos2.dat">
<Link>data\NIST\Lanczos2.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Lanczos3.dat">
<Link>data\NIST\Lanczos3.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Lew.dat">
<Link>data\NIST\Lew.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Longley.dat">
<Link>data\NIST\Longley.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Lottery.dat">
<Link>data\NIST\Lottery.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Mavro.dat">
<Link>data\NIST\Mavro.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\MGH09.dat">
<Link>data\NIST\MGH09.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\MGH10.dat">
<Link>data\NIST\MGH10.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\MGH17.dat">
<Link>data\NIST\MGH17.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Michelso.dat">
<Link>data\NIST\Michelso.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Misra1a.dat">
<Link>data\NIST\Misra1a.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Misra1b.dat">
<Link>data\NIST\Misra1b.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Misra1c.dat">
<Link>data\NIST\Misra1c.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Misra1d.dat">
<Link>data\NIST\Misra1d.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Nelson.dat">
<Link>data\NIST\Nelson.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\NoInt1.dat">
<Link>data\NIST\NoInt1.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\NoInt2.dat">
<Link>data\NIST\NoInt2.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Norris.dat">
<Link>data\NIST\Norris.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\NumAcc1.dat">
<Link>data\NIST\NumAcc1.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\NumAcc2.dat">
<Link>data\NIST\NumAcc2.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\NumAcc3.dat">
<Link>data\NIST\NumAcc3.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\NumAcc4.dat">
<Link>data\NIST\NumAcc4.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Pontius.dat">
<Link>data\NIST\Pontius.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Rat42.dat">
<Link>data\NIST\Rat42.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Rat43.dat">
<Link>data\NIST\Rat43.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Roszman1.dat">
<Link>data\NIST\Roszman1.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\SiRstvt.dat">
<Link>data\NIST\SiRstvt.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\SmLs01t.dat">
<Link>data\NIST\SmLs01t.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\SmLs02t.dat">
<Link>data\NIST\SmLs02t.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\SmLs03t.dat">
<Link>data\NIST\SmLs03t.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\SmLs04t.dat">
<Link>data\NIST\SmLs04t.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\SmLs05t.dat">
<Link>data\NIST\SmLs05t.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\SmLs06t.dat">
<Link>data\NIST\SmLs06t.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\SmLs07t.dat">
<Link>data\NIST\SmLs07t.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\SmLs08t.dat">
<Link>data\NIST\SmLs08t.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\SmLs09t.dat">
<Link>data\NIST\SmLs09t.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Thurber.dat">
<Link>data\NIST\Thurber.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Wampler1.dat">
<Link>data\NIST\Wampler1.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Wampler2.dat">
<Link>data\NIST\Wampler2.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Wampler3.dat">
<Link>data\NIST\Wampler3.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Wampler4.dat">
<Link>data\NIST\Wampler4.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\data\NIST\Wampler5.dat">
<Link>data\NIST\Wampler5.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="App.config" />
<None Include="..\..\data\NIST\Meixner.dat">
<Link>data\NIST\Meixner.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="paket.references" />
</ItemGroup>
<ItemGroup>
@ -683,4 +415,5 @@
<Paket>True</Paket>
</Reference>
</ItemGroup>
<ItemGroup />
</Project>
Loading…
Cancel
Save