Class NpyFormat
Provides static methods to save and load files saved in NumPy's .npy format.
Inheritance
Namespace: ISynergy.Framework.Mathematics.IO
Assembly: ISynergy.Framework.Mathematics.dll
Syntax
public static class NpyFormat : object
Methods
View SourceLoad<T>(Stream)
Loads an array of the specified type from a stream.
Declaration
public static T Load<T>(Stream stream)
where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream containing the matrix to be loaded. |
Returns
Type | Description |
---|---|
T | The array to be returned. |
Type Parameters
Name | Description |
---|---|
T | The type to be loaded from the npy-formatted file. |
Load<T>(Stream, out T)
Loads an array of the specified type from a stream.
Declaration
public static T Load<T>(Stream stream, out T value)
where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream containing the matrix to be loaded. |
T | value | The object to be read. This parameter can be used to avoid the need of specifying a generic argument to this function. |
Returns
Type | Description |
---|---|
T | The array to be returned. |
Type Parameters
Name | Description |
---|---|
T | The type to be loaded from the npy-formatted file. |
Load<T>(Byte[])
Loads an array of the specified type from a byte array.
Declaration
public static T Load<T>(byte[] bytes)
where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | bytes | The bytes that contain the matrix to be loaded. |
Returns
Type | Description |
---|---|
T | The array to be returned. |
Type Parameters
Name | Description |
---|---|
T | The type to be loaded from the npy-formatted file. |
Load<T>(Byte[], out T)
Loads an array of the specified type from a file in the disk.
Declaration
public static T Load<T>(byte[] bytes, out T value)
where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | bytes | The bytes that contain the matrix to be loaded. |
T | value | The object to be read. This parameter can be used to avoid the need of specifying a generic argument to this function. |
Returns
Type | Description |
---|---|
T | The array to be returned. |
Type Parameters
Name | Description |
---|---|
T | The type to be loaded from the npy-formatted file. |
Load<T>(String)
Loads an array of the specified type from a file in the disk.
Declaration
public static T Load<T>(string path)
where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to the file containing the matrix to be loaded. |
Returns
Type | Description |
---|---|
T | The array to be returned. |
Type Parameters
Name | Description |
---|---|
T |
Load<T>(String, out T)
Loads an array of the specified type from a file in the disk.
Declaration
public static T Load<T>(string path, out T value)
where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to the file containing the matrix to be loaded. |
T | value | The object to be read. This parameter can be used to avoid the need of specifying a generic argument to this function. |
Returns
Type | Description |
---|---|
T | The array to be returned. |
Type Parameters
Name | Description |
---|---|
T | The type to be loaded from the npy-formatted file. |
LoadJagged(Stream, Boolean)
Loads a jagged array from a stream.
Declaration
public static Array LoadJagged(Stream stream, bool trim = true)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream containing the matrix to be loaded. |
System.Boolean | trim | Pass true to remove null or empty elements from the loaded array. |
Returns
Type | Description |
---|---|
Array | A jagged array containing the values available in the given stream. |
LoadJagged(Byte[])
Loads a jagged array from an array of bytes.
Declaration
public static Array LoadJagged(byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | bytes | The bytes that contain the matrix to be loaded. |
Returns
Type | Description |
---|---|
Array | A jagged array containing the values available in the given stream. |
LoadJagged(String)
Loads a jagged array from a file in the disk.
Declaration
public static Array LoadJagged(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to the file containing the matrix to be loaded. |
Returns
Type | Description |
---|---|
Array | A jagged array containing the values available in the given stream. |
LoadMatrix(Stream)
Loads a multi-dimensional array from a stream.
Declaration
public static Array LoadMatrix(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream containing the matrix to be loaded. |
Returns
Type | Description |
---|---|
Array | A multi-dimensional array containing the values available in the given stream. |
LoadMatrix(Byte[])
Loads a multi-dimensional array from an array of bytes.
Declaration
public static Array LoadMatrix(byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | bytes | The bytes that contain the matrix to be loaded. |
Returns
Type | Description |
---|---|
Array | A multi-dimensional array containing the values available in the given stream. |
LoadMatrix(String)
Loads a multi-dimensional array from a file in the disk.
Declaration
public static Array LoadMatrix(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to the file containing the matrix to be loaded. |
Returns
Type | Description |
---|---|
Array | A multi-dimensional array containing the values available in the given stream. |
Save(Array)
Saves the specified array to an array of bytes.
Declaration
public static byte[] Save(Array array)
Parameters
Type | Name | Description |
---|---|---|
Array | array | The array to be saved to the array of bytes. |
Returns
Type | Description |
---|---|
System.Byte[] | A byte array containig the saved array. |
Save(Array, Stream)
Saves the specified array to a stream using the npy format.
Declaration
public static ulong Save(Array array, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Array | array | The array to be saved to disk. |
Stream | stream | The stream to which the file will be saved. |
Returns
Type | Description |
---|---|
System.UInt64 | The number of bytes written when saving the file to disk. |
Save(Array, String)
Saves the specified array to the disk using the npy format.
Declaration
public static ulong Save(Array array, string path)
Parameters
Type | Name | Description |
---|---|---|
Array | array | The array to be saved to disk. |
System.String | path | The disk path under which the file will be saved. |
Returns
Type | Description |
---|---|
System.UInt64 | The number of bytes written when saving the file to disk. |