Skip to content

Guidance on encoder/decoder for compound types? #63

Answered by Apollo3zehn
marklam asked this question in Q&A
Discussion options

You must be logged in to vote

I was able to make a successful roundtrip (encode then decode) with the following unit test code:

[Fact]
public void Test()
{
    const string filePath = "test.h5";
    const string datasetName = "data";

    var writeData = new Peak[] {
        new Peak(1.1, 2.2f),
        new Peak(3.1, 4.5f)
    };

    // encode data
    var writeFile = new H5File
    {
        [datasetName] = writeData
    };

    var options = new H5WriteOptions(
        IncludeStructProperties: true
    );

    writeFile.Write(filePath, options);

    // decode data
    var readFile = H5File.OpenRead(filePath);
    var readData = readFile.Dataset(datasetName).Read<Peak[]>();

    Assert.True(writeData.SequenceEqual(r…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by marklam
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants