1- using Microsoft . VisualStudio . TestTools . UnitTesting ;
1+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
22using System ;
33using System . Collections . Generic ;
44using System . Text ;
55using NumSharp . Extensions ;
66using System . Linq ;
77using NumSharp ;
8+ using System . Numerics ;
89
910namespace NumSharp . UnitTest . Creation
1011{
1112 [ TestClass ]
1213 public class NdArrayMGridTest
1314 {
15+ // These C# NDArray declarations were generated using ndarray-generatory.py,
16+ // which is located in the README.md of this NumSharp.UnitTest project
17+ // using the following Python code:
18+ /*
19+ aa, bb = np.mgrid[0:5, 0:3]
20+ cc, dd = np.mgrid[0:3, 0:5]
21+ ee, ff = np.mgrid[0:5, 0:5]
22+ cSharp.asCode2D("a53", aa)
23+ cSharp.asCode2D("b53", bb)
24+ cSharp.asCode2D("a35", cc)
25+ cSharp.asCode2D("b35", dd)
26+ cSharp.asCode2D("a55", ee)
27+ cSharp.asCode2D("b55", ff)
28+ */
29+
30+ static NDArray a53 = new NDArray ( new Int32 [ ] {
31+ 0 , 0 , 0 ,
32+ 1 , 1 , 1 ,
33+ 2 , 2 , 2 ,
34+ 3 , 3 , 3 ,
35+ 4 , 4 , 4
36+ } , new Shape ( new int [ ] { 5 , 3 } ) ) ;
37+
38+ static NDArray b53 = new NDArray ( new Int32 [ ] {
39+ 0 , 1 , 2 ,
40+ 0 , 1 , 2 ,
41+ 0 , 1 , 2 ,
42+ 0 , 1 , 2 ,
43+ 0 , 1 , 2
44+ } , new Shape ( new int [ ] { 5 , 3 } ) ) ;
45+
46+ static NDArray a35 = new NDArray ( new Int32 [ ] {
47+ 0 , 0 , 0 , 0 , 0 ,
48+ 1 , 1 , 1 , 1 , 1 ,
49+ 2 , 2 , 2 , 2 , 2
50+ } , new Shape ( new int [ ] { 3 , 5 } ) ) ;
51+
52+ static NDArray b35 = new NDArray ( new Int32 [ ] {
53+ 0 , 1 , 2 , 3 , 4 ,
54+ 0 , 1 , 2 , 3 , 4 ,
55+ 0 , 1 , 2 , 3 , 4
56+ } , new Shape ( new int [ ] { 3 , 5 } ) ) ;
57+
58+ static NDArray a55 = new NDArray ( new Int32 [ ] {
59+ 0 , 0 , 0 , 0 , 0 ,
60+ 1 , 1 , 1 , 1 , 1 ,
61+ 2 , 2 , 2 , 2 , 2 ,
62+ 3 , 3 , 3 , 3 , 3 ,
63+ 4 , 4 , 4 , 4 , 4
64+ } , new Shape ( new int [ ] { 5 , 5 } ) ) ;
65+
66+ static NDArray b55 = new NDArray ( new Int32 [ ] {
67+ 0 , 1 , 2 , 3 , 4 ,
68+ 0 , 1 , 2 , 3 , 4 ,
69+ 0 , 1 , 2 , 3 , 4 ,
70+ 0 , 1 , 2 , 3 , 4 ,
71+ 0 , 1 , 2 , 3 , 4
72+ } , new Shape ( new int [ ] { 5 , 5 } ) ) ;
73+
1474 [ TestMethod ]
1575 public void BaseTest ( )
1676 {
17- var X = np . arange ( 1 , 11 , 2 ) . mgrid ( np . arange ( - 12 , - 3 , 3 ) ) ;
18-
19- NDArray x = X . Item1 ;
20- NDArray y = X . Item2 ;
77+ var V53 = np . arange ( 0 , 5 , 1 ) . mgrid ( np . arange ( 0 , 3 , 1 ) ) ;
78+ var V35 = np . arange ( 0 , 3 , 1 ) . mgrid ( np . arange ( 0 , 5 , 1 ) ) ;
79+ var V55 = np . arange ( 0 , 5 , 1 ) . mgrid ( np . arange ( 0 , 5 , 1 ) ) ;
2180
22-
81+ Assert . AreEqual ( V53 . Item1 , a53 ) ;
82+ Assert . AreEqual ( V53 . Item2 , b53 ) ;
83+ Assert . AreEqual ( V35 . Item1 , a35 ) ;
84+ Assert . AreEqual ( V35 . Item2 , b35 ) ;
85+ Assert . AreEqual ( V55 . Item1 , a55 ) ;
86+ Assert . AreEqual ( V55 . Item2 , b55 ) ;
2387 }
24-
2588 }
26-
27- }
89+ }
0 commit comments