-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNpzFormat.cs
98 lines (85 loc) · 3.94 KB
/
NpzFormat.cs
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Collections;
using System.IO;
using System.Linq;
namespace ChainerModelLoader
{
/// <summary> A npz format. </summary>
class NpzFormat
{
public static void Load<T>(byte[] bytes, out T value) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
{
using (var dict = Load<T>(bytes))
{
value = dict.Values.First();
}
}
public static void Load<T>(string path, out T value) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
{
using (var dict = Load<T>(path))
{
value = dict.Values.First();
}
}
public static void Load<T>(Stream stream, out T value) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
{
using (var dict = Load<T>(stream))
{
value = dict.Values.First();
}
}
public static NpzDictionary<T> Load<T>(byte[] bytes) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
{
return Load<T>(new MemoryStream(bytes));
}
public static NpzDictionary<T> Load<T>(string path, out NpzDictionary<T> value) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
{
return value = Load<T>(new FileStream(path, FileMode.Open));
}
public static NpzDictionary<T> Load<T>(Stream stream, out NpzDictionary<T> value) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
{
return value = Load<T>(stream);
}
public static NpzDictionary<T> Load<T>(string path) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
{
return Load<T>(new FileStream(path, FileMode.Open));
}
public static NpzDictionary<T> Load<T>(Stream stream) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
{
return new NpzDictionary<T>(stream);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Loads a matrix. </summary>
///
/// <param name="bytes"> The bytes. </param>
///
/// <returns> The matrix. </returns>
////////////////////////////////////////////////////////////////////////////////////////////////////
public static NpzDictionary<Array> LoadMatrix(byte[] bytes)
{
return LoadMatrix(new MemoryStream(bytes));
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Loads a matrix. </summary>
///
/// <param name="path"> Full pathname of the file. </param>
///
/// <returns> The matrix. </returns>
////////////////////////////////////////////////////////////////////////////////////////////////////
public static NpzDictionary<Array> LoadMatrix(string path)
{
return LoadMatrix(new FileStream(path, FileMode.Open));
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Loads a matrix. </summary>
///
/// <param name="stream"> The stream. </param>
///
/// <returns> The matrix. </returns>
////////////////////////////////////////////////////////////////////////////////////////////////////
public static NpzDictionary<Array> LoadMatrix(Stream stream)
{
return new NpzDictionary(stream);
}
}
}