Skip to content

Commit

Permalink
feat: Getting ready for release
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamBebko committed Sep 29, 2020
1 parent 7db8778 commit aa42974
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 31 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 15 additions & 4 deletions H5Loader_Project/.idea/.idea.H5Loader_Project/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityH5Loader;

namespace Packages.H5Loader.Samples.SampleLoad {
namespace SampleLoad {
public class H5SampleLoader : MonoBehaviour {
// Start is called before the first frame update

Expand All @@ -16,34 +17,34 @@ void Start() {
Debug.Log($"Loading file: {filePath}");

Debug.Log("Loading ints dataset");
int[] ints = global::H5Loader.H5Loader.LoadIntDataset(filePath, "integers");
int[] ints = H5Loader.LoadIntDataset(filePath, "integers");
foreach (int i in ints) {
Debug.Log($"ints: {i}");
}


Debug.Log("Loading floats dataset");
float[] floats = global::H5Loader.H5Loader.LoadFloatDataset(filePath, "floats");
float[] floats = H5Loader.LoadFloatDataset(filePath, "floats");
foreach (float i in floats) {
Debug.Log($"floats: {i}");
}

Debug.Log("Loading strings dataset");
string[] strings = global::H5Loader.H5Loader.LoadStringDataset(filePath, "strings");
string[] strings = H5Loader.LoadStringDataset(filePath, "strings");
foreach (string i in strings) {
Debug.Log($"strings: {i}");
}

Debug.Log("Loading 2d ints dataset");
int[,] int2d = global::H5Loader.H5Loader.Load2dIntDataset(filePath, "twoD");
int[,] int2d = H5Loader.Load2dIntDataset(filePath, "twoD");
for (int i = 0; i < int2d.GetLength(0); i++) {
for (int j = 0; j < int2d.GetLength(1); j++) {
Debug.Log($"twoD int: {i}, {j} = {int2d[i,j]}");
}
}

Debug.Log("Loading 2d int dataset as floats");
float[,] float2d = global::H5Loader.H5Loader.Load2dFloatDataset(filePath, "twoD");
float[,] float2d = H5Loader.Load2dFloatDataset(filePath, "twoD");
for (int i = 0; i < int2d.GetLength(0); i++) {
for (int j = 0; j < int2d.GetLength(1); j++) {
Debug.Log($"twoD float: {i}, {j} = {int2d[i,j]}");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "SampleLoad",
"references": [
"H5Loader"
"UnityH5Loader"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
using System.Text;
using HDF.PInvoke;
using JetBrains.Annotations;
using UnityEngine;

namespace H5Loader {
namespace UnityH5Loader {
public static class H5Loader {

static readonly ulong[] MaxDimensions = {10000, 10000, 10000};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "H5Loader",
"name": "UnityH5Loader",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Directly supports loading:
* 2D arrays of: `float`, `int`
* Advanced: Also supports generic methods to load any datatype, but these generic types do not play well with unity, and must usually be cast manually to unity-friendly types. They are typically types `byte`, `ulong`, `double`, etc.

Tested on macos and windows 64 bit. Should also work on linux but untested.

If h5 is from python, it's easier (especially for strings) if datasets are created from numpy arrays with the dtype set to `'i8'` (int), `'float'`, or `'S'` (string).

## Installation

#### Unity 2020.1 and later (recommended):
Expand Down Expand Up @@ -45,5 +49,10 @@ reference the H5Loader assembly and namespace.
There are public static methods for each kind of supported datatype. For example:

```c#
H5Loader.Load
```
using UnityH5Loader;

float[] loadedFloatArray = H5Loader.LoadFloatDataset(filePath, "floatdatasetname");
int[,] loadedInt2DArray = H5Loader.Load2dIntDataset(filePath, "Dtwointdatasetname");
```

See included sample (accessible in package manager window) for more examples.

0 comments on commit aa42974

Please sign in to comment.