@@ -19,16 +19,6 @@ public void NumpyLoadTest()
1919 int [ ] b = np . Load < int [ ] > ( mem ) ;
2020 }
2121
22- [ TestMethod ]
23- public void NumpyLoad1DimTest ( )
24- {
25- int [ ] arr = np . Load < int [ ] > ( @"data/1-dim-int32_4_comma_empty.npy" ) ;
26- Assert . IsTrue ( arr [ 0 ] == 0 ) ;
27- Assert . IsTrue ( arr [ 1 ] == 1 ) ;
28- Assert . IsTrue ( arr [ 2 ] == 2 ) ;
29- Assert . IsTrue ( arr [ 3 ] == 3 ) ;
30- }
31-
3222 [ TestMethod ]
3323 public void NumpyNPZRoundTripTest ( )
3424 {
@@ -42,5 +32,80 @@ public void NumpyNPZRoundTripTest()
4232 var d2 = np . Load_Npz < Array > ( ms ) ;
4333 Assert . IsTrue ( d2 . Count == 2 ) ;
4434 }
35+
36+ [ TestMethod ]
37+ // [DataRow(@"data/arange_f2_le.npy")] // Ignore: Half-precision floats not supported
38+ [ DataRow ( @"data/arange_f4_le.npy" ) ]
39+ [ DataRow ( @"data/arange_f8_le.npy" ) ]
40+ [ DataRow ( @"data/arange_i1.npy" ) ]
41+ [ DataRow ( @"data/arange_i2_le.npy" ) ]
42+ [ DataRow ( @"data/arange_i4_le.npy" ) ]
43+ [ DataRow ( @"data/arange_i8_le.npy" ) ]
44+ [ DataRow ( @"data/arange_u1.npy" ) ]
45+ [ DataRow ( @"data/arange_u2_le.npy" ) ]
46+ [ DataRow ( @"data/arange_u4_le.npy" ) ]
47+ [ 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
57+ public void load_Arange ( string path )
58+ {
59+ NDArray arr = np . load ( path ) ;
60+ // Assert.IsNotNull(arr);
61+ // Assert.IsTrue(arr.ndim == 1 && arr.shape[0] > 0);
62+
63+ for ( int i = 0 ; i < arr . shape [ 0 ] ; ++ i )
64+ {
65+ int value = ( int ) Convert . ChangeType ( arr . GetValue ( i ) , typeof ( int ) ) ;
66+ Assert . AreEqual ( i , value ) ;
67+ }
68+ }
69+
70+ [ TestMethod ]
71+ [ 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
74+ public void load_HelloWorld ( string path )
75+ {
76+ string [ ] arr = np . Load < string [ ] > ( path ) ;
77+
78+ Assert . AreEqual ( "Hello" , arr [ 0 ] ) ;
79+ Assert . AreEqual ( "World" , arr [ 1 ] ) ;
80+ }
81+
82+ [ TestMethod ]
83+ [ DataRow ( @"data/mgrid_i4.npy" ) ]
84+ // [DataRow(@"data/mgrid_i4_fortran_order.npy")] // Ignore: Fortran order not supported
85+ public void load_Mgrid ( string path )
86+ {
87+ NDArray arr = np . load ( path ) ;
88+
89+ for ( int i = 0 ; i < arr . shape [ 0 ] ; i ++ )
90+ {
91+ for ( int j = 0 ; j < arr . shape [ 1 ] ; j ++ )
92+ {
93+ Assert . AreEqual ( i , ( int ) arr . GetValue ( 0 , i , j ) ) ;
94+ Assert . AreEqual ( j , ( int ) arr . GetValue ( 1 , i , j ) ) ;
95+ }
96+ }
97+ }
98+
99+ [ TestMethod ]
100+ [ DataRow ( @"data/scalar_b1.npy" , false ) ]
101+ [ DataRow ( @"data/scalar_i4_le.npy" , 42 ) ]
102+ // [DataRow(@"data/scalar_i4_be.npy", 42)] // Ignore: Big-endian types not supported
103+ public void load_Scalar ( string path , object expected )
104+ {
105+ NDArray arr = np . load ( path ) ;
106+
107+ Assert . AreEqual ( Shape . Scalar , arr . shape ) ;
108+ Assert . AreEqual ( expected , arr . GetValue ( 0 ) ) ;
109+ }
45110 }
46111}
0 commit comments