Skip to content

Commit cdbc86e

Browse files
committed
Add test for np.LoadMatrix
1 parent ab93df2 commit cdbc86e

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

test/NumSharp.UnitTest/APIs/np.load.Test.cs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public void NumpyNPZRoundTripTest()
3434
}
3535

3636
[TestMethod]
37-
// [DataRow(@"data/arange_f2_le.npy")] // Ignore: Half-precision floats not supported
3837
[DataRow(@"data/arange_f4_le.npy")]
3938
[DataRow(@"data/arange_f8_le.npy")]
4039
[DataRow(@"data/arange_i1.npy")]
@@ -45,20 +44,9 @@ public void NumpyNPZRoundTripTest()
4544
[DataRow(@"data/arange_u2_le.npy")]
4645
[DataRow(@"data/arange_u4_le.npy")]
4746
[DataRow(@"data/arange_u8_le.npy")]
48-
// [DataRow(@"data/arange_f2_be.npy")] // Ignore: Big-endian types not supported
49-
// [DataRow(@"data/arange_f4_be.npy")] // Ignore: Big-endian types not supported
50-
// [DataRow(@"data/arange_f8_be.npy")] // Ignore: Big-endian types not supported
51-
// [DataRow(@"data/arange_i2_be.npy")] // Ignore: Big-endian types not supported
52-
// [DataRow(@"data/arange_i4_be.npy")] // Ignore: Big-endian types not supported
53-
// [DataRow(@"data/arange_i8_be.npy")] // Ignore: Big-endian types not supported
54-
// [DataRow(@"data/arange_u2_be.npy")] // Ignore: Big-endian types not supported
55-
// [DataRow(@"data/arange_u4_be.npy")] // Ignore: Big-endian types not supported
56-
// [DataRow(@"data/arange_u8_be.npy")] // Ignore: Big-endian types not supported
5747
public void load_Arange(string path)
5848
{
59-
NDArray arr = np.load(path);
60-
// Assert.IsNotNull(arr);
61-
// Assert.IsTrue(arr.ndim == 1 && arr.shape[0] > 0);
49+
NDArray arr = np.load(path);
6250

6351
for (int i = 0; i < arr.shape[0]; ++i)
6452
{
@@ -69,19 +57,15 @@ public void load_Arange(string path)
6957

7058
[TestMethod]
7159
[DataRow(@"data/hello_S5.npy")]
72-
// [DataRow(@"data/hello_U5_be.npy")] // Ignore: Unicode strings not supported
73-
// [DataRow(@"data/hello_U5_le.npy")] // Ignore: Unicode strings not supported
7460
public void load_HelloWorld(string path)
7561
{
7662
string[] arr = np.Load<string[]>(path);
77-
7863
Assert.AreEqual("Hello", arr[0]);
7964
Assert.AreEqual("World", arr[1]);
8065
}
8166

8267
[TestMethod]
8368
[DataRow(@"data/mgrid_i4.npy")]
84-
// [DataRow(@"data/mgrid_i4_fortran_order.npy")] // Ignore: Fortran order not supported
8569
public void load_Mgrid(string path)
8670
{
8771
NDArray arr = np.load(path);
@@ -99,11 +83,18 @@ public void load_Mgrid(string path)
9983
[TestMethod]
10084
[DataRow(@"data/scalar_b1.npy", false)]
10185
[DataRow(@"data/scalar_i4_le.npy", 42)]
102-
// [DataRow(@"data/scalar_i4_be.npy", 42)] // Ignore: Big-endian types not supported
10386
public void load_Scalar(string path, object expected)
10487
{
10588
NDArray arr = np.load(path);
89+
Assert.AreEqual(expected, arr.GetValue(0));
90+
}
10691

92+
[TestMethod]
93+
[DataRow(@"data/scalar_b1.npy", false)]
94+
[DataRow(@"data/scalar_i4_le.npy", 42)]
95+
public void LoadMatrix_Scalar(string path, object expected)
96+
{
97+
Array arr = np.LoadMatrix(path);
10798
Assert.AreEqual(expected, arr.GetValue(0));
10899
}
109100
}

0 commit comments

Comments
 (0)