forked from SciSharp/NumSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnp.load.Test.cs
More file actions
46 lines (42 loc) · 1.25 KB
/
np.load.Test.cs
File metadata and controls
46 lines (42 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NumSharp;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace NumSharp.UnitTest.APIs
{
[TestClass]
public class NumpyLoad
{
[TestMethod]
public void NumpyLoadTest()
{
int[] a = {1, 2, 3, 4, 5};
byte[] mem = np.Save(a);
int[] b = np.Load<int[]>(mem);
}
[TestMethod]
public void NumpyLoad1DimTest()
{
int[] arr = np.Load<int[]>(@"data/1-dim-int32_4_comma_empty.npy");
Assert.IsTrue(arr[0] == 0);
Assert.IsTrue(arr[1] == 1);
Assert.IsTrue(arr[2] == 2);
Assert.IsTrue(arr[3] == 3);
}
[TestMethod]
public void NumpyNPZRoundTripTest()
{
int[] arr = np.Load<int[]>(@"data/1-dim-int32_4_comma_empty.npy");
var d = new Dictionary<string, Array>();
d.Add("A/A",arr);
d.Add("B/A",arr); // Tests zip entity.Name
var ms = new System.IO.MemoryStream();
np.Save_Npz(d,ms,leaveOpen:true);
ms.Position = 0L;
var d2 = np.Load_Npz<Array>(ms);
Assert.IsTrue(d2.Count == 2);
}
}
}